php – reference
- How to encrypt/Decrypt, a number or string or a combination of the two, using a PHP function?
- Unix / Linux Security: Secure your box using (autoban) Denyhosts
- Standalone Access the Wordpress database using $wpdb
- script.aculo.us is a set of JavaScript libraries to enhance the user interface of web sites
- VMerge – the best utility to visually compare the file and merge or modify the two versions
This Post will be continuously updated with comments, help text about php and the usage:
Question: What the difference between include() and include_once() was. php.net says include_once only includes a file once. Does this mean if I use include() I can access variables from the included file anywhere in my script?
Answer:include_once() will not include a file that has already been included. include() will include a file every time. include_once() is useful if you have php scripts which include scripts which include scripts. If 2 of the scripts include the same file then you might get variables and other things being overwritten. Using include_once() ensures you get the functionality that the scripts need but without any side effects.
For example, I have two files, once called functions.php and another is header.php. I include functions.php, and another file called globals.php and I also include functions.php, if I do the include(), my php script will error out. I will get an error saying one of my functions has already been used, why? because I included the file functions.php twice, once in the header and again in globals.php. so to avoid getting an error, it would just be safe to use include_once() instead of include() function.
Following Google Searches Lead To This Post:
how to reference results in php

Comments
No comments yet.