CancelImage Upload

PHP 5.3 includes goto operator

Ever wanted to jump to another section within your code? The goto operator included in PHP 5.3 gives you just that option.

Here is an example of the code:

<?php

goto lable1;

echo 'This area of the code will be jumped over.';

lable1:

echo 'This text will end up being displayed in your browser.';

?>

Resulting in:

This text will end up being displayed in your browser.

Note that the goto operator is not unrestricted. The target lable that you wish to jump to must be within the same function and file. You cannot jump out of a function or leap into one. Jumping into a loop or switch is also not possible.

Need help with some code? Post a help thread as guest:
Login
Want to leave a comment?

No problem. Just enter your email and password below.


register | home | reminder
Posted by Garren Harland on September 11, 2009, 11:36 am.
Let's face it: only the biggest Photo enthusiasts on the planet will want to spend endless amounts of time resizing hundreds of images one at a time. Your average individual or web designer neither has the will or the passion for that kind of display of commitment.
Click here to read on.
Posted by Garren Harland on September 5, 2009, 10:39 pm.
If you want to give your users a specific code you will need to make sure that it really is random and unique. To accomplish this task PHP has a suitable function to offer, as it usually does.
Click here to read on.
Posted by Garren Harland on September 5, 2009, 1:14 pm.
The following page will discuss how to load an image's size details into an array. These details can come in handy with functions to create thumbnail versions of an image, or simply to specify an image's exact dimensions inside an image tag.
Click here to read on.
Posted by Garren Harland on September 5, 2009, 11:58 am.
If you own an interactive website where your users can upload their files, you will need to insure that each file has a unique name that can be used as an identifier. One way to accomplish this task is to add a timestamp to the filename. Granted two users could upload a file with exactly the same name at exactly the same time. But unless you have a website with billions of visitors per day you should be safe.
Click here to read on.
Posted by Garren Harland on September 5, 2009, 11:16 am.
While deleting a folder is no more difficult than deleting a file (though requiring a different set of functions), there are a few things that need to be taken into account. For starters that the file will not be removable till you have deleted each of it's files one by one. To accomplish this you will need to use a combination of the function readdir() to load all the filenames within a folder, and then one by one deleting them with the file delete function that I have previously discussed.
Click here to read on.
Posted by Garren Harland on September 5, 2009, 10:43 am.
While deleting a file in PHP only requires one simple function, you will want to contain it in a pack of if statements that indeed check for whether or not the file first of all exists, and if it does you will want to know if it has indeed been deleted.
Click here to read on.
Posted by Garren Harland on August 30, 2009, 6:33 pm.
If you are looking to send both a HTML and Plain Text version of an email in PHP, you will require a more advanced format of the PHP mail() function. To make this work first of all a HTML and Plain Text alternative have to be written.
Click here to read on.
Posted by Garren Harland on August 30, 2009, 4:59 pm.
Cookies are a useful tool for returning visitors. For instance login details and other items can be stored, and old session states from the last visits can be stored based on these.
Click here to read on.
Posted by Garren Harland on August 30, 2009, 4:17 pm.
A lot of programmers struggle to understand the principle behind headers, and how they are supposed to be defined right at the start of a pages code. It is no good defining them halfway down the page.
Click here to read on.
Posted by Garren Harland on August 19, 2009, 8:19 pm.
If you are building a site indexing website that needs to scan a page's title and meta tags the PHP function get_meta_tags() is the thing that dreams are made out of. Sure, you could write a bunch of regular expressions to extract meta tags and all their information from a website. But then again you could save yourself the time and practice your gloating face instead!
Click here to read on.
Posted by Garren Harland on August 19, 2009, 3:26 pm.
The Message Digest Algorithm designed by RSA Data Security, Inc. can help keep your user's passwords safe, even if for instance someone was capable of obtaining the user database with your passwords in them.
Click here to read on.
Posted by Garren Harland on August 17, 2009, 3:33 pm.
Let's say you have a variable named path, and all that you really require is the name of the file at the end of the path. Through some bizarre combination of programming functions and code structures you have also only been left with the path, and therefore have no way of singularly accessing the files name.
Click here to read on.
Posted by Garren Harland on August 17, 2009, 2:54 pm.
Disk space is one of those things most programmers rarely think about. Until the moment it is all used up that is! Lucky PHP has a function with the sole purpose of returning the amount of free disk space left within a specified location.
Click here to read on.
Posted by Garren Harland on August 17, 2009, 2:18 pm.
There are numerous reasons why a HTML file upload forms may fail to work. The most common errors are found in the coding of the HTML form itself. Based on this I will go through a short checklist for you to make sure that all the required elements are present in your HTML form before claiming that your host has done something wrong.
Click here to read on.
Posted by Garren Harland on August 7, 2009, 8:26 pm.
Here is how you automatically start a file download once a user enters onto a page. Note, the user of course has to be willing to download the file, and can choose not to. If you are looking to force some software onto your visitors you are in the wrong place. If instead however you are looking for a simple download on load for an install shield for instance, carry on reading.
Click here to read on.
Posted by Garren Harland on August 7, 2009, 5:24 pm.
Most browsers plain and simple have not got a clue about how to deal with mp3 files. If you link to a PDF or word document they will play along, open a new window and display the document. Not so with MP3s. On your standard Internet Explorer (yes, even on version 8), it will just try to open the MP3 as a page, and will then give you an error message as if it was your fault for trying to give it an impossible task.
Click here to read on.
Posted by Garren Harland on August 5, 2009, 10:28 pm.
On a dynamic website, such as a form, users often get the feeling they can post all kinds of dodgy images to their heart's desire. Now while most webmasters would either A. Let their visitors have their fun, or B. Go nuclear, and ban their visitors from interacting with HTML code, there is another way.
Click here to read on.
Posted by Garren Harland on August 2, 2009, 12:13 pm.
If your website has a file upload facility, the last thing you will want is your visitors being able to upload any file to their hearts desire. Especially the upload of executable files could put a lot of your other users at risk if they chose to download it.
Click here to read on.
Posted by Garren Harland on August 1, 2009, 11:11 pm.
The php function filesize() will return exactly as the name indicates the size of a specified file. The following example will return the file size in a measurement of bytes.
Click here to read on.
Posted by Garren Harland on August 1, 2009, 7:24 pm.
If you need to dynamically create a directory in PHP, mkdir() is the function that you are looking for. All that it requires is a specified path to the folder that you want to create.
Click here to read on.
Posted by Garren Harland on August 1, 2009, 4:04 pm.
Using the function copy(), a file can be cloned to a specified destination. As the following example displays first the original file along with it's location needs to be provided, followed by a target location and name for the copied file.
Click here to read on.
Posted by Garren Harland on August 1, 2009, 1:04 pm.
With the PHP function chmod() you can modify a folder or files read, write and execute rights. This is done by first specifying the path and folder, followed by the according octal code. Three modes can be specified for each user group.
Click here to read on.
Posted by Garren Harland on August 1, 2009, 12:33 pm.
To return the path and name of a script with PHP the following two variables can be used. Both of them are server variables, which generally convey a lot of useful information on server details and settings.
Click here to read on.
Posted by Garren Harland on August 1, 2009, 10:33 am.
Cached pages are any AJAX using programmer's worst nightmare. What use is a background news feed that is reloaded every 30 seconds if it constantly displays the same cached information? Clearly a forced update is needed!
Click here to read on.
Posted by Garren Harland on July 30, 2009, 1:34 pm.
Ever wanted to store every website a user has ever come through from to get an accurate picture of the origin of your traffic? While your stats tool may offer such a feature putting together your own table will give you a far more accurate insight as to where your visitors are coming from.
Click here to read on.
Posted by Garren Harland on July 30, 2009, 11:45 am.
The following variable can come in handy if you are attempting to write your own stats tool, or if you are merely interested in what type of browsers your visitors are surfing your site with. After all, for testing sake you might come across one or two rare browsers which you did not know about, and can therefore make sure that your website does indeed work as intended.
Click here to read on.
Posted by Garren Harland on July 16, 2009, 4:08 pm.
Before menacing users can be blocked their IP-Address needs to be captured and monitored. Here is one way to do so. Create a table called visitors into which you can store IP-Addresses.
Click here to read on.
Posted by Garren Harland on July 13, 2009, 5:47 pm.
Uploading multiple files in PHP is not very different from uploading a single file. The only adjustment being that instead of one variable containing the files details, the variable $userfile_name for instance would become an array.
Click here to read on.
Posted by Garren Harland on July 13, 2009, 4:53 pm.
The amount of memory available to your scripts in PHP can be changed using one of the following three methods.
Click here to read on.
Posted by Garren Harland on July 13, 2009, 4:23 pm.
To change your web server's file upload limits with the following lines of code you may need to request the permission to do so from your host. This should be less of a problem if your website is located on an in house server.
Click here to read on.
Everyday English GmbH • 8105 Regensdorf, Switzerland • Tel: +41 (0)44 840 03 68 • www.mydesigntool.cominfo@mydesigntool.com