Sunday, August 19, 2012

Codeigniter Directory Structure

Now that you have CodeIgniter downloaded and unzipped, take a minute to look at the file structure. Below illustrates the initial folder structure you ’ ll see.

You can see three folders and two files in the codeigniter folder. The three folders are application, system and Codeigniter user guide and the files are index.php and license.txt.Below is the detailed description about the directories.

The application Folder— The application folder contains the application you ’ re building. Basically, this
folder contains your models, views, controllers, and other code (like helpers and class
extensions). In other words, this folder is where you will work for the project development.

cache — The cache folder contains all cached pages for your application. In Chapter 9 , you learn
more about caching and how to turn your super - speedy development application into a
blazingly fast live application.
Config— The Know more about config folderfolder is the area where you set the configuration for your application.
Controllers— In this folder you will place your class files developed for your application
core— In this folder you will place your base class files of your application
errors— In this folder you will place your application specific error logs
helpers— In this folder you will place the include files use full for your application
hooks— In this folder you will place the support files use full for your application
language— In this folder you will place language  macros/ define constants.
libraries— In this folder you will place your own developed libraries useful for your application
logs — The logs folder is the folder CodeIgniter uses to write error and other logs to.
models— In this folder you will place your data base fetching logic in
thirdparty— In this folder you can place any plugins used for your application
views— Most of your work will be in this folder, you will place your html template files. 

The system/ Folder
The system/ folder is where all the action happens. This folder contains all the CodeIgniter code of
consequence, organized into various folders:

core — The core folder is where CodeIgniter ’ s core classes live. You have almost no
reason to go in here. All of your work will occur in the application folder. Even if your intent is
to extend the CodeIgniter core, you would do it with hooks, and hooks live in the application
folder.
database — The database folder contains core database drivers and other database utilities. Again,
there ’ s no good reason for you to be in this folder.
fonts — The fonts folder contains font - related information and utilities. Again, there ’ s no reason
to spend any time here.
helpers — The helpers folder contains standard CodeIgniter helpers (such as date, cookie, and
URL helpers). You ’ ll make frequent use of helpers in your CodeIgniter career and can even
extend helpers thanks to improvements introduced in CodeIgniter version 1.6.
language — The language folder contains language files. You can ignore it for now.
libraries — The libraries folder contains standard CodeIgniter libraries (to help you with e - mail,
calendars, file uploads, and more). You can create your own libraries or extend (and even
replace) standard ones, but those will be saved in the application/libraries directory to keep
them separate from the standard CodeIgniter libraries saved in this particular folder.

For more info visit codeigniter site at www.codeigniter.com

Thursday, August 16, 2012

Downloading CodeIgniter

You can download the latest version of CodeIgniter by going to www.codeigniter.com and clicking the Download CodeIgniter button on the home page as shown in the below figure.



When you click the button, you ' ll get a dialog for downloading a ZIP archive. Either open it in your unzip utility or save it to your hard drive and then open it.

Sunday, August 12, 2012

URI routing in Codeigniter

The routes.php file lets you remap URI requests to specific controller functions. For example, you may
have a controller named site with 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 pages function 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 at welcome, because you ’ re going to create a welcome
controller for the project associated with this book.

To know more about URI routing Please visit the below link
http://codeigniter.com/user_guide/general/routing.html

Sunday, November 6, 2011

What is the difference between urlencode and urldecode ?

The difference between urlencode and urldecode is
URLencode is used to encode a string to be passed through URL to a web page. URLencode replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits.

Use this link to get more stuff on Urlencode http://www.w3schools.com/tags/ref_urlencode.asp


URLdecode is used to decode the encoded URL string . Decodes any %## encoding in the given string

What is the difference between array_slice() and array_splice()?

The difference between array_slice() and array_splice()

array_splice() is used to remove some elements from an array and replace with specified elements.
Below are some code examples:
<?php
$input = array("red", "green", "blue", "yellow");
array_splice($input, 2);
// $input is now array("red", "green")

$input = array("red", "green", "blue", "yellow");
array_splice($input, 1, -1);
// $input is now array("red", "yellow")

$input = array("red", "green", "blue", "yellow");
array_splice($input, 1, count($input), "orange");
// $input is now array("red", "orange")

$input = array("red", "green", "blue", "yellow");
array_splice($input, -1, 1, array("black", "maroon"));
// $input is now array("red", "green",
// "blue", "black", "maroon")

$input = array("red", "green", "blue", "yellow");
array_splice($input, 3, 0, "purple");
// $input is now array("red", "green",
// "blue", "purple", "yellow");
?>

 array_slice() is used to extract a slice of the array. Below are some example codes:

<?php
$input = array("a", "b", "c", "d", "e");

$output = array_slice($input, 2); // returns "c", "d", and "e"
$output = array_slice($input, -2, 1); // returns "d"
$output = array_slice($input, 0, 3); // returns "a", "b", and "c"

// note the differences in the array keys
print_r(array_slice($input, 2, -1));
print_r(array_slice($input, 2, -1, true));
?>
The above example will output:


Array
(
[0] => c
[1] => d
)
Array
(
[2] => c
[3] => d
)






What is the difference between unlink and unset ?

The difference between unlink and unset is given below:

Unlink is used to delete a file for a given path.
where as
Unset is used to delete a value of a variable.

What is Codeigniter?

Codeigniter is a PHP framework and follows MVC architecture. It is an open source. It provides a great flexibility to PHP coders with its built in functions. This framework is used to develop full featured web applications. This framework is easy to learn and there are no coding restrictions to follow, we can use core PHP also. There is no need of learning a new template language for this framework. Below image illustrates the flow of logic in the codeigniter system.

Follow this URL to know more about codeigniter http://codeigniter.com/
Download the latest version here http://codeigniter.com/download.php
Follow this link to view User guide http://codeigniter.com/user_guide/