WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Newbie Notes #6 - A true lie
Categories : PHP, Beginner Guides, Variables Click here to Update Your Picture
Simon Booth
Date : Apr 21st 2004
Grade : 5 of 5 (graded 2 times)
Viewed : 5098
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Simon Booth
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

NewbieNotes is a little series of tips for people who are new to PHP to give them a few handy tips that the more experienced of us use often

I sometimes feel sorry for ASP developers, they miss one lovely thing we've had for a good while now. We can tell when false actually is false (they can't)

I distinctly remember reading an article in a 'technical' computer magazine where the author had no idea at all why we needed to know the dirrefence - I suppose his brain rotted through that conbstant exposure to VB!

The difference between something being false or true is, classically, whether it's zero or not. That's how the CPU handles it, after all.

The most well known example of the difference in PHP is the strpos() function. A searched for string can start right at the beginning. As PHP's index to a string starts at zerolooking for 'the' in 'the quick brown fox' would return a zero.

If it's important to find out whether 'the' is in the string an if statement won't cut it! Well, unless you use PHP, of course...

PHP knows the difference between the number zero and the boolean value false. Many functions return either something or false. You can tell the difference in PHP (poor ASP suckers!)

if($var) { do something } will fail if $var is ither zero or false

if($var !== false) { do something } will let zero thru but block flase


Similarly

if($var === false) { do something } will block everything except a false value (not zero)


Whenever you see that a function returns false for some condition use it to your advantage - take pity on the ASP crowd...



Newbie Notes #5 - To double quote, or single quote, that is the question
Categories : PHP, Beginner Guides, Variables
Automatic global variable definer
Categories : PHP, Variables, Beginner Guides
How to implement a session tracking system.
Categories : PHP, Sessions, Variables
Simple Session example
Categories : PHP, Beginner Guides, Sessions
Script to check values being submitted by POST or GET method from a form. This script may help diagnose what variables are being supplied by a browser to other php scripts.
Categories : HTML, Variables, Debugging, PHP, HTTP
Newbie Notes #7 - Ridiculous regex
Categories : PHP, Beginner Guides, Regexps
Real simple example of removing HTML tags from text then changing \n (new line) to <br>. Could be used in a forum for instance.
Categories : HTML, PHP, HTML and PHP, Beginner Guides
PHP Function for Random Digits
Categories : PHP, Beginner Guides
Link Submition - Allow your visitors to submit links to the site.
Categories : PHP, Arrays, Filesystem, Beginner Guides
Cut your MySQL Connections to 1 line of code
Categories : PHP, Beginner Guides, Databases, MySQL
getting the name of the current script and query string
Categories : PHP, Global Variables, Variables, URLs
Convert a File database into MySQL
Categories : PHP, Filesystem, Databases, MySQL, Beginner Guides
for each record, do this to the first record, and do that to any subsequent record
Categories : PHP, Databases, MySQL, Beginner Guides
Current Page's URL using PHP
Categories : PHP, Beginner Guides, Global Variables
News management class
Categories : PHP, PHP Classes, Beginner Guides