PHP
From Site5Wiki
Subpages:
- Dew-NewPHPLinks
- PHP
- PHP/PEAR
- PHP/PHP-Nuke
- PHP/php.ini
- PHP/PhpAdsNew
- PHP/PHPauction
- PHP/PhpBB
- PHP/PhpCOIN
- PHP/PHPList
- PHP/PHPMailer
- PHP/PHP Support Tickets
- PHP/Post-Nuke
- PHP/Smarty
- PHP/Snippets
- PHPMyAdmin
- PHPMyAdmin/PHPMyAdmin interface languages
- PHProjekt
- PHPSurveyor
PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.
PHP has enjoyed a great deal of success over the years, and is one of the most requested offerings across the web hosting industry. So of course, Site5 offers PHP. In fact, Site5 offers versions 4 and 5, which are available on all our hosting plans automatically.
Contents |
PHP Versions
By default on new Site5 hosting accounts, files ending in the extension .php will be parsed using PHP version 5. Files ending in .php4 will be parsed using PHP version 4. If you wish to override this default and have all files be parsed using PHP4, a .htaccess file can be placed in the directory you wish to use version 4 for .php files (if you want it site wide, just put the .htaccess file in your public_html directory). This .htaccess file needs to contain the following line somewhere in it (if this is all you're using this .htaccess file for, this would be the only line in the file):
AddHandler application/x-httpd-php4 .php
This will cause Apache to parse .php files as PHP4. As nothing has been specified to the contrary, .php4 files will also still be parsed by PHP4.
Command line (SSH) Parsing
To use PHP you can use:
php script.php
or for PHP4, you would use: /usr/bin/php4 script.php
Current Installations
Yes, we do have both versions installed and available to every single customer.
last updated: --Tom 12:35, 25 January 2008 (EDT)
Version 4.x: 4.4.7 Version 5.x: 5.2.1
- viewable PHPinfo (4): orestes.site5.com/info.php
- viewable PHPinfo (5): orestes.site5.com/info.php5
PHP for Beginners
Contents of this series of articles:
If you came here to learn about elementary PHP 4 or basic PHP 5, this is for you. Enjoy!
PHP 101 (part 1): Down the Rabbit Hole
An introduction to PHP’s variables and operators.
PHP 101 (part 2): Calling All Operators
The rest of the PHP operators (there are many), and simple form processing.
PHP 101 (PART 3): Looping the Loop
Basic control structures explained.
PHP 101 (PART 4): The Food Factor
Arrays, PHP array functions, and what it all means.
PHP 101 (PART 5): Rank and File
Everything you’re ever likely to need to know about dealing with external files from a PHP script.
PHP 101 (PART 6): Functionally Yours
All about functions, arguments, passing by reference, globals and scope.
PHP 101 (PART 7): The Bear Necessities
A gentle introduction to object oriented programming in PHP 4 and PHP 5.
PHP 101 (PART 8): Databases and Other Animals
All about connecting to a MySQL database from PHP, using the mysql or mysqli extensions.
(PHP 101 (PART 9): SQLite My Fire!
Introducing another database: SQLite.)
PHP 101 (part 10): A Session In The Cookie Jar
Sessions and cookies – how to keep track of visitors to your site.
PHP 101 (part 11): Sinfully Simple
An introduction to PHP’s easiest method for dealing with XML.
PHP 101 (part 12): Bugging Out
Basic error handling.
PHP 101 (part 13): The Trashman Cometh
A primer in basic security.
PHP 101 (part 14): Going to the Polls
Putting the pieces together – a first Web application.
PHP 101 (part 15): No News is Good News
Creating a simple RSS news aggregator.
- PHP cheatsheet thanks to ilovejackdaniels.com —
also on Flickr (
feed for all of his cheatsheets)
PHP Configuration (php.ini)
Site5 has the default configuration for PHP located at /usr/local/lib/php.ini (http://wiki.site5.com/Php.ini), although you can override these default settings by utilizing a customized local config in the directory that the given php script will be executed from. For example, a custom php.ini for the script http://yourdomin.com/something/somethingelse/index.php will be located at (document_root)/something/somethingelse/php.ini - while http://yourdomain.com/script.php will be located at (document root)/php.ini. Note that the 'document root' for the main domain will always be public_html/ (/home/<username>/public_html).
Customized php.ini
You can copy the default php.ini from http://wiki.site5.com/Php.ini or you can use this fancy one-liner from your shell access.
$ php -i | grep php.ini | grep -i path | sed 's/.* \///' | awk '{ printf("cp /%s/php.ini .",$1) | "sh" }'
This will place a new php.ini file in your current directory. You can download this file, edit it in any text editor, save and re-upload the file to the desired location and the scripts will start using it immediately. Make sure you set the permissions on the file to be 644 so the server has access to read it.
Adding the ability for PHP to 'include' remote files
Edit your php.ini as described above, and either find or add the system variable 'allow_url_include' and set it to read '=on'.
... ;;;;;;;;;;;;;;;;;; ; Fopen wrappers ; ;;;;;;;;;;;;;;;;;; ; Whether to allow the treatment of URLs (like http:// or ftp://) as files. allow_url_fopen = On allow_url_include = On ; Define the anonymous ftp password (your email address) ;from="john@doe.com" ...
PHP Modules
Site5 compiles in a slew of commonly requested modules for PHP, enabling the scripting language to make use of various features not found in its core installation. Here is a list of the default modules we offer on PHP4:
bcmath calendar ctype curl domxml EXIF FTP gd gettext IMAP mbstring mcrypt mhash MySQL openssl overload pcre POSIX pspell session sockets standard tokenizer wddx XML XMLRPC XSLT Zend Optimizer zip zlib
The list of modules available by default on PHP5 differs slightly. Here is the default list for version 5:
bcmath calendar ctype curl date DOM EXIF FTP gd gettext hash iconv IMAP LIBXML mbstring mcrypt mhash MySQL openssl pcre PDO pdo_sqlite POSIX Reflection session SimpleXML sockets SPL SQLite standard tokenizer wddx XML xmlreader XMLRPC xmlwriter Zend Optimizer zlib
PHP Resources
PHP is a widely used language, and as such there are a wide variety of resources available on the internet. While we couldn't possibly hope to provide you with a full list, here are a few of the sites that Site5 staff have found useful in the past:
- php.net -- The home of PHP
-
daily news feed
-
Introductory tutorial
- Available in the following languages via pull-down menu:
- Available in the following languages via pull-down menu:
-
- codegrrl.com -- help with PHP and MySQL
taking the grr out of coding!
- phpfreaks.com -- Site devoted to PHP Articles, Tutorials, and more.
- All projects tagged PHP on SWiK.net: link to tag;
tag's feed
- PHPMyEdit:
Instant MySQL Table Editor and PHP Code Generator
Books We Recommend
Core Web Application Development with PHP and MySQL, by Marc Wandschneider ISBN 9780131867161
:
- Find this book at
O'Reilly
- Find this book at
Barnes & Noble
- Find this book at
BooksPrice
- Find this book at
InformIT
- Find this book at
Powells' Books
No Nonsense XML Web Development With PHP by Thomas Myer ISBN 9780975240205
:
- Find this book at
O'Reilly
- Find this book at
Barnes & Noble
- Find this book at
BooksPrice
- Find this book at
InformIT
- Find this book at
Powells' Books
A practical and concise book that teaches XML from the ground up. This tutorial style presents various XML methodologies and techniques in an easy to understand way, whilst building a fully functional Content Management System by the end of the book.
Building Tag Clouds in Perl and PHP, by Jim Bumgardner ISBN 9780596527945
:
- Find this book at
O'Reilly
- Find this book at
Barnes & Noble
- Find this book at
BooksPrice
- Find this book at
InformIT
- Find this book at
Powells' Books
*: a list of
specific code snippets, tips and tricks
Related wiki pages: .htaccess, PEAR, Scripting and Development Guide, Smarty, Installed software and their versions

