PHP

CodeIgniter: Use GET Parameters for OAuth or Facebook

2010
02
Apr
1

Codeignitor destroys your GET parameters, because it does not use it, however for applications that use OAuth, Facebook Applications or Facebook authentication using Facebook connect, GET parameters are required.

In order to retrieve GET parameters from Code Ignitor, first we have to change the config.php, uri_protocol to PATH_INFO,
this solves 404 Errors with GET parameters on Codeigniter

/*
|--------------------------------------------------------------------------
| URI PROTOCOL

Read More

Solve "Cannot modify header information - headers already sent by *.php"

2010
17
Mar


Warning: Cannot modify header information - headers already sent by somefile.php (output started at somefile.php:###) in somefile.php on line ###

This Warning is shown by PHP when you use the header function to output headers or use the setcookie function to set cookies after any echo or content which is not inside PHP tag.

echo "Hello World";
header("Location: /redirect.php");

Hello World !!! 
<?php header("Location: /redirect.php");?>

Read More

Removing index.php From URL in CodeIgniter

2010
14
Mar
2

In Code Ignitor by default all URLs except the default home contains "index.php" by default in the URL, For example http://localhost/index.php/class/function.

In order to make the URLs "cleaner", we have to remove "index.php" from the URL. This is done using the mod_rewrite module in apache to redirect all traffic to index.php/. The following code inside .htaccess does the redirection.

Read More

PHP file_get_contents giving garbled output

2010
08
Mar

Are you getting garbled values when using file_get_contents fetching an external URL (website scrapping using php) and wondering what went wrong ? The content is appearing to have wierd characters instead of normal HTML output because of GZIP output encoding by the website you are fetching.

 <?php echo file_get_contents("http://www.example.com"); ?>

You can fix this issue in multiple ways.

Method 1 : Accept-Encoding

Read More

Syndicate content