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.