PHP Web Development Tutorials

PHP Web Development Tutorials and Articles
  Title / Author Replies
Views
All PHP coders are aware of the mail() function in PHP, which can be used to send mails. On Linux systems we ussually have Sendmail program installed, if someone is facing a problem sending mails with mail() function, they can alternatively use Sendmail to send mails. For sending mails using...
4
34,658
Many times its required that we truncate a long string and add ellipsis to the end of the truncated string. Here's a function which does exactly that. function truncate( $varb, $num ) { $dnum = intval($num); if (strlen($varb)>$dnum) { $nvarb = substr($varb, 0,...
0
4,006
Do a WHOIS query for any domain using the script below.:) <form method="POST" action= "<?$_SERVER?>"> <label>Do a WHOIS query:</label> <P> <INPUT name="domain" SIZE="20" MAXLENGTH="22"> <INPUT TYPE="SUBMIT" VALUE="Check name"> <INPUT TYPE="RESET" VALUE="Clear"> </P> </FORM>
2
7,257
At some point, most developers have a need to create graphs. I've known some to get frustrated and end up exporting the data to a spreadsheet, rather than relying upon the graphing capabilities of Open Office or Excel. That can be the way to go in certain cases, but not because there's no...
1
12,590
Introduction Suppose you want to know the age of a person given her birth date. Letís say her birth date is "09-23-1969". Although in this case you might say that we donít need a program to compute the age, but assuming there are 1000s of records in your database and for every person you have to...
0
65,215
Here's a function which will format the passed bytes into KB,MB,GB...appropriately. function GetSize ($sizeb) { $sizekb = $sizeb / 1024; $sizemb = $sizekb / 1024; $sizegb = $sizemb / 1024; $sizetb = $sizegb / 1024; $sizepb = $sizetb / 1024; if ($sizeb > 1) {$size =...
0
2,445
Shell Sort function in PHP <? function shellsort($elements,$length) { $k=0; $gap=(int) ($length / 2); while($gap>1) { $k++;
0
6,090
Many times we require to format a number to output with thousand place comma separator, here is a function will help you do so. function numcomma ($value) { if(strpos($value,".")) { $decimalval = substr($value,strpos($value,".")+1); $value =...
0
2,285
Title says it all but to reemphasize that below PHP code block validate an email address. Its always good to have a client side validation for faster user responses but backend check is also needed for user not having client side scripting on. <?php function emailsyntax_is_valid($email) { ...
0
3,296
How to show the no. of users online on your site using PHP & MySQL. Step1: Creating the database Create a new table called 'useronline', with 3 fields inside a table. The fields are timestamp, ip and file. Below is the SQL to create the table. CREATE TABLE useronline ( timestamp...
1
4,040
PHP offers one alternative - a special Log class that comes courtesy of PEAR, the PHP Extension and Application Repository (http://pear.php.net). In case you didn't know, PEAR is an online repository of free PHP software, including classes and modules for everything from data archiving to XML...
0
11,891
Manier times we require to create logs of various activities/errors in our web applications, so here we'll look into how to achieve that. Logging data to a file in PHP can be as simple or as complex as you want to make it. Break it down, though, and it all comes down to these three simple lines...
0
16,543
The PHP Extension and Application Repository (PEAR) is an open source structured library of packages for PHP developers. These packages provide routines which solve problems PHP developers regularly face: sending structured e-mail (such as an HTML attachment), interacting with different databases...
0
9,729
There are times when we require to put a calendar in some web appplication of ours,writing the code to generate a calendar from scratch is painstaking and waste of time. So PEAR comes to rescue with its Calendar package. The package gives a ton of features, below you'll find a simple program to...
0
6,987
I never recommend using " (double quotes) when programming with PHP. Always use ' (single quotes) unless you need the features of " (double quotes). You might think it's much easier to write code as: echo "Today is the $day of $month"; However, using single quotes forces variables to be...
0
6,675
Well, I always had a problem identifying my MP3 files because of their vague filenames like, "Track 1.mp3" or "Bryan Adams 1.mp3", I was wondering whether I could rename the file depending upon the MP3 tags, so I came with up this script with reads MP3 tags and renames the file according to the...
0
4,649
To display the data by splitting them in pages is very important if you have chances of more records to be displayed. function page_records() { global $page,$pagecount,$perpage; $arr = $_GET; if (is_array($arr)) { foreach($arr AS $_arrykey => $_arryval) {
0
8,530
How to optimize your PHP installation to handle large file uploads. Though PHP presents a very versatile and user friendly interface for handling file uploads, the default installation is not geared for working with files in excess of 2 Mega Bytes. This article will help you...
0
7,886
This script is a simple file based counter. This is meant for sites that do not run a db and instead, use a file and a cookie. It isn't the best I've seen but it's simple. Consider this as a tutorial. Just create a file called counter.txt and put this where you want to display the...
0
4,822
I like coding PHP, in Perl we can change an associative array to a list then to a string. In case if we wish to do the same in PHP, we need to write some user functions for that purpose. Here are two functions which will convert Array to String and vice-versa. //array to string ...
0
5,322