codeigniter routes page

The  routes.php filelets you remap URI requests to specific controller functions. For example, you may
have a controller named sitewith a function named index. The URI for this controller/function
combination might be:
http://www.example.com/site/index
Furthermore, if your site controller had a pagesfunction that accepted a numeric ID for database
lookup, the URI might look like this:
http://www.example.com/site/pages/4
In some cases, you might want to remap one or more of these default routes. For example, the second
example might be better displayed as this:
http://www.example.com/about_us/
In that case, your routes.php file would contain a rule like this:
$route[‘about_us’] = “site/pages/4”;
For right now, though, this kind of manipulation falls under “ advanced  usage, ”  so  don ’ t  worry  too  much
about it. However, please do note that this kind of thing is possible. Also, be aware that two “ reserved
routes ” exist: default_controller and scaffolding_trigger.
$route[‘default_controller’] = “welcome”;
The default_controller route tells CodeIgniter which controller should be loaded if no controller is
identified. For simplicity ’ s sake, keep this setting.

CodeIgniter Libraries

CodeIgniter libraries help you do your job faster and more efficiently. Each libraryis really a PHP class
with various methods that you can use once the library is loaded by a controller.

CodeIgniter gives  the following libraries:
Benchmarking —  The   Benchmarking libraryis always active. Use it to determine the time
difference between any two marked points in code and to calculate memory usage.

Calendaring —  The   Calendaring librarymust be loaded by a controller. Use it to dynamically
create calendars for given months and years, with some control over formatting and appearance.

Config —  The   Config libraryis initialized automatically by the system. Use it to retrieve
configuration information.

Database —  The   Database libraryis a very powerful set of methods that must be loaded. You ’ ll
be using this library so much that the next subsection of this chapter focuses on it exclusively.

Email —  The   Email librarymust be loaded. It includes a very powerful set of tools that simplifies
the job of sending e - mails.

Encryption —  The   Encryption librarymust be loaded. It provides you with powerful two - way
encryption methods.

File Uploading —  The   File Uploading librarymust be loaded. Use this library whenever you need
to handle file uploads. It includes powerful validation features that can restrict a file by mime
type, size in kilobytes, or even image dimensions.

FTP —  The   FTP librarymust be loaded. Use this library to transfer files to a remote server only
standard FTP is supported, by the way.

HTML Table —  The   HTML Table librarymust be loaded. Use this very versatile library to
autogenerate HTML tables from arrays or database result sets.

Image Manipulation —  The   Image Manipulation librarymust be loaded. Use it to resize images,
create thumbnails, crop or rotate images, and watermark images. Some functions require further
PHP support such as GD/GD2.

Input and Security —  The   Input and Security librarymust be loaded. Use it to pre - process  input
data from forms and URLs and to handle some security functions such as guarding against
XSS attacks.

Language —  The   Language librarymust be loaded. Use this library to load different sets of
language files for internationalization.

Loader —  The   Loader libraryis automatically loaded. You will use this library primarily to load
views with your controller, but it is also used to load libraries.

Output —  The   Output libraryis automatically loaded. This library has one main function: Send
the finalized web page to the requesting browser. It is also used for caching.

Pagination — The  Pagination librarymust be loaded. Use this labor - saving library to paginate
database results for performance and usability. You can control how many records to display per
page, how many records to pull from the database, and the look and feel of different parts of the
pagination.

Session —  The   Session librarymust be loaded. Use CodeIgniter ’ s Session library to maintain
state information about a user. This library does not use PHP ’ s  built - in  sessions  —  instead,  it
generates its own session data. Because this library is so important, a separate subsection of this
chapter is devoted to it.

Related Posts:
  • Send Email from a PHP Script you use the mail() function (in combination with a web form in particular), make sure you check it is called from the desired page and protect the form with a CAPTCHA mail(to,subject,message,headers,parameters); <?php… Read More
  • Php Networking Functions There are many functions in php to convert or look up domain name, IP address, protocol, and service information. Domain name/IP address lookups and conversions gethostbynamel() gethostbyname() gethostbyaddr() … Read More
  • php implode array elements php implode array elements Join array elements with a string string. implode(string, arraypieces) Returns a string containing a string representation of all the array elements in the same order,  string between each e… Read More
  • Web-Based MySQL Administration Web-Based MySQL Administration At http://phpwizard.net/phpMyAdmin you will find a PHP Web application that can help you manage MySQL. It enables you to manage a MySQL database using a browser and makes administrative work… Read More
  • php best tutorial-php variables PHP automatically creates variables for all the data it receives in an HTTP request. This can include GET data, POST data, cookie data, and environment variables. The variables are either in PHP's global symbol table or … Read More
  • Advanced Database Techniques PEAR DB is the database primitives shown earlier; it provides several shortcut functions for fetching result rows, as well as a unique row ID system and separate prepare/execute steps that can improve the performance of re… Read More
  • php-use the header() function-php An HTTP (HyperText Transfer Protocol) header is used to send information back and forth between the server and the client (the Web browser). Normally this information is in the form of HTML, which is why the address for Web … Read More
  • Php Operators PHP Operators The following table lists the operators from highest to lowest precedence. Operators A !, ~, ++, --, @ Right *, /, % Left +, -, . Left <<, >> Left <… Read More
  • php urlencode - Make a strong GET Query String  php urlencode URL-encodes a string, converting spaces into plus (+ ) signs. urlencode() makes a string safe to use as part of a URL. It does this by encoding every character within the string that may be misi… Read More
  • php-static variables A static variable retains its value between calls to a function but is visible only within that function. IT declare a variable static with the static keyword. function test_counter ( ) { static $counter = 0; $counte… Read More
  • PHP-Renaming Files and Directories Renaming  Files and Directories There are a few useful file and directory functions built-in to PHP which I'll cover in brief here. They include renaming and deleting files as well as listing files located in a… Read More
  • difference between print and echo - php print( ) is a function, echo is a language construct.  This means that print( ) returns a value, while echo doesn't. You can include print( ) but not echo in larger expressions. echo is  run very fast than  … Read More
  • PHP variable-related functions Cast a value from one type to other type:- doubleval(), intval(), strval() Set  type of a variable:- settype() Verify  the type of a variable:- is_array(), is_bool(), is_double(), is_float(), is_int(), … Read More
  • php -Mail Functions The mail() function requires an installed and working email subsystem for sending mail. The program to be used is defined by configuration directives in the php.ini file. A common pitfall is that these are not set up cor… Read More
  • php Sessions page Php Sessions are used to help maintain the values of variables across multiple web pages. This is done by creating a unique session ID that is sent to the client browser. The browser then sends the unique ID back on eac… Read More