Posts tagged "PHP"

Syntax Error PHP Parse

PHP syntax errors are easy to make, and if unchecked can popup from the rarely used corners of a complicated application. If you short on time finding a debugger of some sort, don’t want to mess with installing software on the server, or just plain lazy, try this out at the command line Read more…


Adding an element to the beginning of an array in PHP

// Create an array
$a = new array("apple", "orange");
 
// Prepend an element to the array
array_unshift($a, "raspberry");
 
// Prepend a couple more elements to the array
array_unshift($a, "pineapple", "watermelon");

The PHP add to array function: array_push()

There are two ways to add an element to the end of an array in PHP. Read more…


How to remove elements from an array in PHP

// Create an array
$a = new array("orange", "apple", "pineapple");
 
// Remove the apple from the middle of the array
unset($a[1]);
 
// Create an associative array
$a = new array("dogs" => 4, "cats" => 9, "birds" =>2);
 
// Remove the birds from the array
unset($a['birds']);

Another method for checking whether a URL exists

In a previous article we demonstrated a simple method for discovering whether or not a URL exists. The following code accomplishes the same thing, but offers a little more control. Read more…


How to send mail in PHP

This functionality is one of the most needed in PHP web applications out there. You may want send a reminder to an employee about a meeting, or you might want to send an email from PHP to a user who has forgotten their password. There is a function called mail built into PHP that is quite powerful. Read more…


Checking whether a URL exists in PHP

There is no built in function to check if a particular URL exists, but you can easily write one. The following is a simple method, or you can try this one which takes more code, but allows more control. Read more…


Working with session variables in PHP

Let’s say you are creating a website where users need to login. How do you track a user’s id from page to page, or even verify that a user is logged in when they should be? You can use the global $_SESSION variable! Read more…


Next Page »