PHP Tutorials

History and origin of PHP

  • 2008-08-14
  • Comments
  • Wang Li
  • 630

Some time in 1994 when Rasmus Lerdorf put together a bunch of Perl scripts to track down who was looking at his resume. Little by little, people started to get interested in the scripts, and they were later released as a package "Personal Home Page" tools (the first meaning of PHP). In view of the interest, he wrote a scripting engine and incorporated another tool to parse input from HTML forms: FI, Form Interpreter, thus creating what was called variously PHP/FI or PHP2. This was done around mid 1995.
Read More

Different versions of PHP - History and evolution of PHP

  • 2008-11-21
  • Comments
  • Andi, Stig and Derick
  • 630

It was eight years ago, when Rasmus Lerdorf first started developing PHP/FI. He could not have imagined that his creation would eventually lead to the development of PHP as we know it today, which is being used by millions of people. The first version of "PHP/FI," called Personal Homepage Tools/Form Interpreter, was a collection of Perl scripts in 1995. One of the basic features was a Perl-like language for handling form submissions, but it lacked many common useful language features, such as for loops.
Read More

Getting Started with PHP

  • 2008-08-14
  • Comments
  • Wang Li (from php.net)
  • 630

For the first and most common form, you need three things: PHP itself, a web server and a web browser. You probably already have a web browser, and depending on your operating system setup, you may also have a web server (e.g. Apache on Linux and MacOS X; IIS on Windows). You may also rent webspace at a company. This way, you don't need to set up anything on your own, only write your PHP scripts, upload it to the server you rent, and see the results in your browser.
Read More

Variables in PHP

  • 2008-11-21
  • Comments
  • Andi, Stig and Derick
  • 630

Variables in PHP are quite different from compiled languages such as C and Java. This is because their weakly typed nature, which in short means you don’t need to declare variables before using them, you don’t need to declare their type and, as a result, a variable can change the type of its value as much as you want.
Read More

Constants in PHP

  • 2008-11-22
  • Comments
  • Andi, Stig and Derick
  • 630

In PHP, you can define names, called constants, for simple values. As the name implies, you cannot change these constants once they represent a certain value. The names for constants have the same rules as PHP variables except that they don’t have the leading dollar sign. It is common practice in many programming languages - including PHP - to use uppercase letters for constant names, although you don’t have to. If you wish, which we do not recommend, you may define your constants as case-insensitive, thus not requiring code to use the correct casing when referring to your constants.
Read More

Strings in PHP

  • 2008-11-21
  • Comments
  • Andi, Stig and Derick
  • 630

Strings in PHP are a sequence of characters that are always internally nullterminated. However, unlike some other languages, such as C, PHP does not rely on the terminating null to calculate a string’s length, but remembers its length internally. This allows for easy handling of binary data in PHP - for example, creating an image on-the-fly and outputting it to the browser. The maximum length of strings varies according to the platform and C compiler, but you can expect it to support at least 2GB. Don’t write programs that test this limit because you’re likely to first reach your memory limit.
Read More

if Statements in PHP

  • 2008-11-22
  • Comments
  • Andi, Stig and Derick
  • 630

if statements are the most common conditional constructs, and they exist in most programming languages. The expression in the if statement is referred to as the truth expression. If the truth expression evaluates to true, the statement or statement list following it are executed; otherwise, they’re not.
Read More

switch Statements in PHP

  • 2008-11-22
  • Comments
  • Andi, Stig and Derick
  • 630

You can use the switch construct to elegantly replace certain lengthy if/ elseif constructs. It is given an expression and compares it to all possible case expressions listed in its body. When there’s a successful match, the following code is executed, ignoring any further case lines (execution does not stop when the next case is reached). The match is done internally using the regular equality operator (==), not the identical operator (===). You can use the break statement to end execution and skip to the code following the switch construct.
Read More

while loops in PHP

  • 2008-11-22
  • Comments
  • Andi, Stig and Derick
  • 630

while loops are the simplest kind of loops. In the beginning of each iteration, the while’s truth expression is evaluated. If it evaluates to true, the loop keeps on running and the statements inside it are executed. If it evaluates to false, the loop ends and the statement(s) inside the loop is skipped. For example, here’s one possible implementation of factorial, using a while loop (assuming $n contains the number for which we want to calculate the factorial):
Read More

do...while Loops in PHP

  • 2008-11-22
  • Comments
  • Andi, Stig and Derick
  • 630

The do...while loop is similar to the previous while loop, except that the truth expression is checked at the end of each iteration instead of at the beginning. This means that the loop always runs at least once.
Read More

for Loops in PHP

  • 2008-11-22
  • Comments
  • Andi, Stig and Derick
  • 630

The start expression is evaluated only once when the loop is reached. Usually it is used to initialize the loop control variable. The truth expression is evaluated in the beginning of every loop iteration. If true, the statements inside the loop will be executed; if false, the loop ends. The increment expression is evaluated at the end of every iteration before the truth expression is evaluated. Usually, it is used to increment the loop control variable, but it can be used for any other purpose as well. Both break and continue behave the same way as they do with while loops. continue causes evaluation of the increment expression before it re-evaluates the truth expression.
Read More

Most Viewed Articles on PHP

Installing PHP with nginx-server under windows

PHP ./configure RESULTING IN [email protected]_2_2_3_... AND UNRESOLVED REFERENCES WITH ORACLE OCI8

PHP 5.1.4 INSTALLATION on Solaris 9 (Sparc)

Building PHP 5.x with Apache2 on SuSE Professional 9.1/9.2

Installing PHP 5.x with Apache 2.x on HP UX 11i and configuring PHP 5.x with Oracle 9i

Cannot load /usr/local/apache/libexec/libphp4.so into server: ld.so.1:......

Setting up PHP in Windows 2003 Server IIS7, and WinXP 64

error: "Service Unavailable" after installing PHP to a Windows XP x64 Pro

Running different websites on different versions of PHP in Windows 2003 & IIS6 platform

Function to convert strings to strict booleans in PHP

Convert IP address to integer and back to IP address in PHP

Function to return number of digits of an integer in PHP

Function to force strict boolean values in PHP

Function to sort array by elements and count of element in PHP

PHP pages does not display in IIS 6 with Windows 2003

Latest Tutorials

Related Tutorials

PHP convert string to lower case

Convert XML to CSV in PHP

PHP code to write to a CSV file for Microsoft Applications

PHP code to write to a CSV file from MySQL query

PHP code to import from CSV file to MySQL

Password must include both numeric and alphabetic characters - Magento

Error: Length parameter must be greater than 0

PHP file upload (Large Files)

PHP file upload prompts authentication for anonymous users

PHP file upload with IIS on windows XP/2000 etc

Multiple File Upload in PHP using IFRAME

Resume or Pause File Uploads in PHP

Exception in module wampmanager.exe at 000F15A0 in Windows 8

Count occurrences of a character in a String in PHP

Handling file locks in PHP

Archived Comments

1. Hi there, a nice tutorial. i wanna ask, what about
View Tutorial          By: Alfa at 2013-03-06 04:04:26

2. hi,
my problem is.......
i use vb.ne

View Tutorial          By: Anirban at 2009-10-25 10:15:13

3. hi..
recipient: 9994852342 message: chadru<

View Tutorial          By: chandrasekaran at 2009-05-04 09:00:47

4. When trying to install Java

i was

View Tutorial          By: Sinmo at 2009-08-30 00:31:33

5. Hi, thanks alot this code works for me , can someo
View Tutorial          By: ann at 2011-03-18 04:50:16

6. Hi,
Please give the better example of resou

View Tutorial          By: Keerthi at 2012-01-11 11:28:24

7. Nice Example...!
View Tutorial          By: Kuldeep Singh at 2009-10-18 23:58:17

8. hello,thanx its really great
View Tutorial          By: sadhana at 2011-08-05 09:35:00

9. Excellent work mate! works like a charm! Lifesaver
View Tutorial          By: jmcg at 2015-01-29 02:31:56

10. Awesome post....
View Tutorial          By: Zeeshan Ali Ansari at 2012-11-24 06:35:20