PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old June 20th, 2003, 05:57 PM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
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.

Reply With Quote
  #2  
Old June 20th, 2003, 06:05 PM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
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

Reply With Quote
  #3  
Old July 19th, 2003, 03:20 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
DYN: 'Strings' === 0

Try it:

PHP Code:
/***
* it is interesting that 'strings'===0
***/
print 'anystring'=='strings are ==0' 'strings are !==0';
print 
'<br />';
print 
'anystring'==='but, strings are not ===0' 'and string are also ===0';
print 
'<br />'

Reply With Quote
  #4  
Old July 19th, 2003, 07:58 PM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 653 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 m 52 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
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.

Reply With Quote
  #5  
Old July 20th, 2003, 11:31 PM
wAr-AnGeL wAr-AnGeL is offline
Forum Security
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Behind You
Posts: 479 wAr-AnGeL User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m
Reputation Power: 7
Send a message via ICQ to wAr-AnGeL Send a message via AIM to wAr-AnGeL
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

Reply With Quote
  #6  
Old July 21st, 2003, 02:55 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
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'));
}

Reply With Quote
  #7  
Old July 28th, 2003, 01:05 PM
CoolAsIce CoolAsIce is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 3 CoolAsIce User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Php : Did You Know


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway