FoxTools.com

Visual FoxPro Tools and Utilities

PHP Information PHP

PHP Solutions I just started reading this book, so far so good.  I am liking it and will give updates as my progress continues.  Ok,  this book was very useful in learning the basics and also has a bunch of good examples.
Advanced PHP Programming  Great book.  A lot more of the more complex stuff.  Like the OOPs stuff and the database stuff.
PHPGoodParts  OK, I think this is the best book that I have read yet.  I think this is a great book to get started working with PHP.  This book seemed to have all the basic information that I would have needed when I FIRST got started.  Give it a shot!
 This really isn't a book but I found a great link to 7 FREE PHP Books.  I haven't had a chance to take a look at them but they do look great for free.

This class is great!!!!.  Simple image manipulation, from resizing to a specific height\width or scaling the image (up or down).  I have used it also to return the image instead of coding the image into the HTML of a page.  VERY useful.

 
/*
* File: SimpleImage.php
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 08/11/06
* Link: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
* http://www.gnu.org/licenses/gpl.html
*
*/
 
class SimpleImage {
 
   var $image;
   var $image_type;
 
   function load($filename) {
 
      $image_info = getimagesize($filename);
      $this->image_type = $image_info[2];
      if( $this->image_type == IMAGETYPE_JPEG ) {
 
         $this->image = imagecreatefromjpeg($filename);
      } elseif( $this->image_type == IMAGETYPE_GIF ) {
 
         $this->image = imagecreatefromgif($filename);
      } elseif( $this->image_type == IMAGETYPE_PNG ) {
 
         $this->image = imagecreatefrompng($filename);
      }
   }
   function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) {
 
      if( $image_type == IMAGETYPE_JPEG ) {
         imagejpeg($this->image,$filename,$compression);
      } elseif( $image_type == IMAGETYPE_GIF ) {
 
         imagegif($this->image,$filename);
      } elseif( $image_type == IMAGETYPE_PNG ) {
 
         imagepng($this->image,$filename);
      }
      if( $permissions != null) {
 
         chmod($filename,$permissions);
      }
   }
   function output($image_type=IMAGETYPE_JPEG) {
 
      if( $image_type == IMAGETYPE_JPEG ) {
         imagejpeg($this->image);
      } elseif( $image_type == IMAGETYPE_GIF ) {
 
         imagegif($this->image);
      } elseif( $image_type == IMAGETYPE_PNG ) {
 
         imagepng($this->image);
      }
   }
   function getWidth() {
 
      return imagesx($this->image);
   }
   function getHeight() {
 
      return imagesy($this->image);
   }
   function resizeToHeight($height) {
 
      $ratio = $height / $this->getHeight();
      $width = $this->getWidth() * $ratio;
      $this->resize($width,$height);
   }
 
   function resizeToWidth($width) {
      $ratio = $width / $this->getWidth();
      $height = $this->getheight() * $ratio;
      $this->resize($width,$height);
   }
 
   function scale($scale) {
      $width = $this->getWidth() * $scale/100;
      $height = $this->getheight() * $scale/100;
      $this->resize($width,$height);
   }
 
   function resize($width,$height) {
      $new_image = imagecreatetruecolor($width, $height);
      imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
      $this->image = $new_image;
   }      
 
}

Every have the need to sort an array on a specific column?  Works like a champ, just remember that the sorted array is RETURNED, the original array is NOT sorted\changed.

function Array_Sort($array, $on, $order = SORT_ASC) {
	$new_array = array();
	$sortable_array = array();
	if (count($array) > 0) {
		foreach ($array as $k => $v) {
			if (is_array($v)) {
				foreach ($v as $k2 => $v2) {
					if ($k2 == $on) {
						$sortable_array[$k] = $v2;
					}
				}
			} else {
				$sortable_array[$k] = $v;
			}
		}
		switch ($order) {
			case SORT_ASC :
				asort($sortable_array);
				break;
			case SORT_DESC :
				arsort($sortable_array);
				break;
		}
		foreach ($sortable_array as $k => $v) {
			$new_array[$k] = $array[$k];
		}
	}
	return $new_array;
}

Return any array of files in the passed directory.

 
function getDirectoryList($directory) {

	// create an array to hold directory list
	$results = array();

	// create a handler for the directory
	$handler = opendir($directory);

	// open directory and walk through the filenames
	while ($file = readdir($handler)) {

		// if file isn't this directory or its parent, add it to the results
		if ($file != "." && $file != "..") {
			$results[] = $file;
		}

	}

	// tidy up: close the handler
	closedir($handler);

	// done!
	return $results;

}

I started using PHP for a new project that I am working on.  I really like it.  Here are a bunch of links that I found useful.

PHP Books

PHP Solutions I just started reading this book, so far so good.  I am liking it and will give updates as my progress continues.  Ok,  this book was very useful in learning the basics and also has a bunch of good examples.
Advanced PHP Programming  Great book.  A lot more of the more complex stuff.  Like the OOPs stuff and the database stuff.
PHPGoodParts  OK, I think this is the best book that I have read yet.  I think this is a great book to get started working with PHP.  This book seemed to have all the basic information that I would have needed when I FIRST got started.  Give it a shot!
 This really isn't a book but I found a great link to 7 FREE PHP Books.  I haven't had a chance to take a look at them but they do look great for free.

The first thing you are going to need is an editor.  I found Aptana and CodeLobster.  I really like using Aptan, it seems like the auto complete and overall program is a little more complete.  Both programs can also be used for JavaScript, HTML and CSS editing.  PhpStorm,  this is THE BEST editor that I have ever used, period.  It isn't free but it is worth EVERY PENNY!  Download and use the evaluation version, you will LOVE it.

Must applications will need to access some form of data,  I found to a video that explains PDO PDO (PHP Data Objects).   PDO provides an interface to accessing data, no matter what type of data, SQL, ODBC or MySQL.  Here are a couple of articles to help geet started with PDO PHP Database Access: Are you doing it Correctly? This link is specificly for ODBC access PDO with ODBC in PHP 5.1 This link contains Object Orientation Basics and in part 4, information on Implementing CRUD methods.

Once you have all your PHP code written you will need solution for your distributied PHP files, unless you are running the server and providing a service.  Take a look at these sites:

Free PHP Encryption Software PHP Encoder PHPCipher
CodeLock ZenGuard  

 Recently I had to do some emailing from PHP.  I found a BUCH of stuff but PHPMailer is what I ended up using, love it and it s FREE and simple.  I downloaded the code from the first link but here is another link to what I think is the paid version.

Ok, once I finally got my appliction run an running doing updates was a MAJOR PITA.  I found a great link to some PHP code for updating your site files.

Recently I starting looking into using a PHP framework,  well there are quite a few choices out there.  PHP Frameworks is a site that compares the features of some of them.  I have started to look into Yii more then the others,  seems really cool and complete.  Version 2.0 is going to be a rewrite of the framework.  I also found a book for the Yii framework, The Yii Book by Larry Ullman.  If you are using Ext JS and Yii EXT4Yii is a framework that is indented to make the integration of the two frameworks a lot simpler.  Have a look.


Here are a few little routines that I found that have been VERY useful.

ArraySort.php

SimpleImage.php

GetDirectoryList.php

 I am always looking for more information and links, so if you have some favorites please send them along.

You are here: Home PHP PHP