|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Php : Did You Know
Don't you just love those little "DID YOU KNOW" screens that show up the first time you run certain apps? I figured I'd start a thread that contains a bunch of "DID YOU KNOW's" for PHP that everyone can add to.
If I see a bunch of really good posts maybe I'll compile them into a list when there are enough of them. I'm prefixing the subject in each entry with "DYN", so the first post will be: DYN: PHPINFO() Where it comes from
__________________
__________________________________________________ _ Wil Moore III, MCP | Integrations Specialist | Senior Consultant Are You Listed...? | DigitallySmooth Inc. Last edited by laidbak : June 20th, 2003 at 06:06 PM. |
|
#2
|
|||
|
|||
|
DYN: PHPINFO() Where it comes from
I'm not sure how many people already knew this, but I always thought the info from the phpinfo() function came straight from the php.ini file.
I've found that it doesn't: If you were to use the following code: Code:
ini_set("include_path", ini_get("include_path").":/usr/lib/php");
phpinfo();
You would notice the include path reports the new setting... not the setting from the php.ini file. Example: include_path = .:/usr/local/lib/php:/usr/lib/php instead of include_path = .:/usr/local/lib/php |
|
#3
|
|||
|
|||
|
DYN: 'Strings' === 0
Try it:
PHP Code:
|
|
#4
|
||||
|
||||
|
DYN: ob_start()/ob_flush();
Quite a bit of people know about this one but I thought I'd post it anyway
ob_start(); -- turns on output buffering, it will take all of the page output and compile them all into a buffer, which allows the page to be compiled and built before it's dumped to the browser. The only things that are sent are the initial headers. ob_flush(); -- dumps everything from the buffer that ob_start creats, and sends all of the output to the browser... These are good for some of those pesky "Headers are already sent" errors that we see so often. |
|
#5
|
|||
|
|||
|
DYN: The magical .phps extension
If your PHP configuration is set to allow it, renaming any .php file to .phps will allow it's source to be read on anyone's browser who opens it. The code will be color-coded, exactly the same as the [PHP] tag in vbulletin.
This is helpful when you need to debug a large script. Remember to remove any sensitive information before doing so however (db passwords, db table names, etc..).
__________________
![]() ![]() "Only Linux users see the end of crashes." - Pl4t0 |
|
#6
|
|||
|
|||
|
DYN: Include can return values
Many PHP developers are familiar with useing the include and require statements to add a piece of code to a calling script, however, many do not know that the include and require statements do return a status code.
If your included file does not contain a return statement the script returns either 1 or 0. 1 if the script executed sucessfully, and 0 if it did not. If there is a return statement in the script, the value passed to it is returned. A quick example would be: if (include_once('show_html.php')) { // processing code here } else { exit (log_error('Error: unable to display html')); } |
|
#7
|
|||
|
|||
|
DYN: Nesting Classes
Although many people may know this anyway, I found it kind of interesting
Although you cant nest a class within another class class foo { function bar() { // will throw error class test { } } } you can, however, define a class within another class if the class is in an include() file function foo { function bar() { // works! include(filecontainingbarclass.php); } } this also works with functions too |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Php : Did You Know |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|