![]() |
| Forums | Gallery | Movies | File Hosting | Classifieds | Jokes | Free Hosting | Free Blogs |
|
|||
|
Web Server Configuration & .htaccess File
Some web servers may ignore .htaccess files unless otherwise configured. Make sure that your web server is configured to read the .htaccess file in your public directory. |
|
|||
|
Best Practices and Closing Tags
File Name : phpinfo.php Purpose : To display the PHP environment variable values Quote:
We didn't forget the closing (?>) PHP tag! We intentionally omit it to avoid unintentional output of whitespace in the response in certain cases. |
|
|||
|
PHP is a famous open source language, which decrease application performance considerbly.
Turn On Error Reporting Immediately during development stage by Code:
error_reporting(E_ALL); Single Quotes and Double Quotes are Very Different echo "Today is the $day of $month"; Instead use the following code : Code:
echo 'Today is the ' . $date[‘day’] . ' of ' . $date['month']; Use /*…*/ commenting system to document your code. It will help in the development of the code or during debugging. |
|
|||
|
Set display_errors value in php.ini set to "0". Otherwise, any errors that are encountered in your code, such as database connection errors, will be output to the end user's browser. A malicious user can learn about the lopphole in the security and can hack the system.
Instead of displaying errors, set the error_log ini variable to "1" and check your PHP error log frequently for caught errors. Alternatively, you can develop your own error handling functions that are automatically invoked when PHP encounters an error, and can email you or execute other PHP code of your choice. Learn more about the set_error_handler() function from PHP manual. |
|
|||
|
Code tested in Firefox browser as random.php
Code:
<?php $r = rand(128,255); $g = rand(128,255); $b = rand(128,255); $tablebg = dechex($r) . dechex($g) . dechex($b); ?> <html> <head> <title> Refresh and see </title> </head> <body bgcolor='<?php echo "#"."$tablebg"; ?>'> This is my Home page with random background color. <br> Refresh and see. </body> </html> |
|
|||
|
The phpinfo() function will list your php.ini variables and scan them for insecure settings. Keep this page in a restricted place and do not allow public access to it. The output of phpinfo() contains information that a potential hacker might find extremely useful.
Code:
<?php phpinfo() ;
|
|
|||
|
* By default the index.php file is included in the URL, but it can be removed using a simple .htaccess file.
* Programmers love to code and hate to write documentation. Well documented program is easy to rebuild and debug. * The only way to really judge an application is to try it and get to know the code. |
![]() |
| Bookmarks |
| Tags |
| .htaccess, php, tips & tricks |
| Thread Tools | |
| Display Modes | |
|
|