Professional Documents
Culture Documents
By
PHP resources
PHP resources
Contents
Contents................................................................................................................ 2
Check for valid email address.............................................................................3
Getting real IP address....................................................................................... 3
Resize Image...................................................................................................... 4
Import CSV File................................................................................................... 5
iPhone & iPod Detection..................................................................................... 5
Display source code of any webpage.................................................................5
Display Facebook fans count..............................................................................5
Download & save a remote image......................................................................6
Send Mail using mail function in PHP..................................................................6
HTTP Redirection................................................................................................ 6
Human Readable Random String .......................................................................6
Parse JSON Data ................................................................................................ 7
Parse XML Data .................................................................................................. 7
Directory Listing in PHP...................................................................................... 8
Unzip a Zip File................................................................................................... 9
Crop Image....................................................................................................... 10
Create Zip Files................................................................................................. 11
Test whether URL exists................................................................................... 12
For more programming information and code..................................................13
PHP resources
PHP resources
Resize Image
Creates a thumbnail from an existing image. $filename is the original filename,
while $tmpname is the actual filesystem name (for example, the temporary
filename used in a PHP upload). Returns an image resource which you can then
output to the browser, or save to a file using imagejpg(), imagepng(), etc.
$xmax;
$newx * $y / $x;
$ymax;
$x / $y * $newy;
PHP resources
PHP resources
HTTP Redirection
<?php
header('Location: http://you_stuff/url.php'); // stick your url here
?>
PHP resources
PHP resources
PHP resources
PHP resources
Crop Image
<?php
$filename= "test.jpg";
list($w, $h, $type, $attr) = getimagesize($filename);
$src_im = imagecreatefromjpeg($filename);
$src_x = '0'; // begin x
$src_y = '0'; // begin y
$src_w = '200'; // width
$src_h = '200'; // height
$dst_x = '0'; // destination x
$dst_y = '0'; // destination y
$dst_im = imagecreatetruecolor($src_w, $src_h);
$white = imagecolorallocate($dst_im, 255, 255, 255);
imagefill($dst_im, 0, 0, $white);
imagecopy($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h);
header("Content-type: image/png");
imagepng($dst_im);
imagedestroy($dst_im);
?>
PHP resources
PHP resources
PHP resources
PHP resources
Programmers help
Programming site
PHP resources