Tag Archives: core PHP

isset() vs. array_key_exists()

I used to think that if a variable was set to NULL isset() would return TRUE—because NULL is a value to which that variable is set. However, the PHP Manual says this is incorrect. The array_key_exists() function avoids this confusion. … Continue reading

Posted in PHP Arrays, PHP Data Value Types, PHP Language Constructs | Tagged , , | Leave a comment

Obliterate a Variable Using unset()

Posted in PHP Data Value Types, PHP Language Constructs | Tagged | Leave a comment

What is stdClass?

The stdClass is a PHP standard predefined class. It is built into PHP. Here are the features of this class: has no methods you create/assign the properties on the fly you can convert arrays to this class you can convert … Continue reading

Posted in PHP Data Value Types, PHP Object Oriented Programming | Tagged , , | Leave a comment

empty() is similar !$a

The function empty() determines whether a variable is considered to be empty. The following things are considered to be empty: It’s the same list as for the things that make $a evaluate to false in an expression. I think this … Continue reading

Posted in PHP Code Snippets, PHP Form Processing, PHP Language Constructs, PHP String | Tagged , , , | 2 Comments

The Not Operator ! Used to Check Form Input

The not logical operator ! seems to have a broader interpretation in PHP than in other languages. This makes it possible to use ! to check form input to determine if a value was supplied. According to documentation !$a is … Continue reading

Posted in PHP Code Snippets, PHP Data Value Types, PHP Form Processing, PHP Language Constructs | Tagged , , | 1 Comment

Is this an Int?

Sample function call: WARNING: The original version of function really_is_int fails to return the appropriate value when passed a zero (0). Zero is an integer as are all negative whole numbers. Sample user defined function really_is_int: I used the original … Continue reading

Posted in PHP Data Value Types, PHP Form Processing | Tagged , , , , | Leave a comment

Urlencode URL Vars

The urlencode function transforms a string into something which is safe to have in a browser’s URL request window. The web server returns the string to its original state. Example:

Posted in Hyperlink as GET, PHP Code Snippets, PHP Form Processing, PHP String | Tagged , , , , , , , | Leave a comment

Discover script’s URL (or parts thereof)

Sample code: See $_SERVER in PHP Manual. Sample code: $_SERVER[‘REQUEST_URI’] The URI which was given in order to access this page; for instance, ‘/index.html’. Compare it to $_SERVER[‘PHP_SELF’]. string basename ( string $path [, string $suffix ] ) Given a … Continue reading

Posted in PHP and Filesystem, PHP Constants, PHP Form Processing, PHP Script Writing | Tagged , | Leave a comment

Strip HTML from Strings and More

Quote from an interview with Michelangelo van Dam: 15) One function that you like (or which you tend to use frequently) I think one particularly stands out: htmlentities($string, ENT_QUOTES, ‘utf-8’); This function escapes output and ensures that your content is … Continue reading

Posted in PHP Form Processing, PHP String | Tagged , , , | Leave a comment

Uppercase/Lowercase String Functions

strtolower() strtoupper() ucfirst() — capitalize the first letter of the string. ucwords() — capitalize the first letter of each word in the string.

Posted in PHP String | Tagged | Leave a comment