WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
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 Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
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
Submit Site
Forex Trading Online forex trading platform

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 : 4024
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 
 

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
Check parameters validity. Paranoia was designed to check the validity of the parameters that a php page will receive after a form submission. It can be used to check the variables sent by POST or GET
Categories : Algorithms, HTML and PHP, PHP, Variables
email new items in db
Categories : PHP, Email, Databases, MySQL, Beginner Guides
clearing variables in php3
Categories : Variables, Arrays, PHP
A very simple PHP single password cookie based login without usernames.
Categories : PHP, Cookies, Security, Beginner Guides
PHP based Contact email form with multiple recipients, text file based, supports departments.
Categories : PHP, Email, Beginner Guides, Filesystem
A simple function to prevent undefined $_POST/$_GET/$_SESSION variable errors
Categories : PHP, Variables, Errors and Logging
Newbie Notes #8 - A cron trick
Categories : PHP, CURL, Beginner Guides
This functions compares the current PHP version with a desired version. Because of the 3 tiered version system, a direct compare of a string to phpversion() will not be accurate.
Categories : PHP Configuration, PHP, Variables
Get the self URL of current page
Categories : PHP, URLs, Beginner Guides
A beginner's session handling class
Categories : PHP, PHP Classes, Sessions, Beginner Guides
Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP, Form Processing, PHP Classes, Data Validation, Beginner Guides
Easy alert box pop-up function
Categories : PHP, Java Script, Beginner Guides
How to control the number of decimal places when outputting numbers.
Categories : PHP, Strings, Variables