PHP Tutorials

History and origin of PHP

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

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
  • 177

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)
  • 177

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
  • 177

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
  • 177

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
  • 177

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
  • 177

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
  • 177

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
  • 177

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
  • 177

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
  • 177

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

Latest Tutorials

Subscribe to Tutorials

Related Tutorials

PHP code to import from CSV file to MySQL

PHP code to write to a CSV file from MySQL query

PHP code to write to a CSV file for Microsoft Applications

Convert XML to CSV in PHP

Password must include both numeric and alphabetic characters - Magento

PHP file upload (Large Files)

PHP file upload prompts authentication for anonymous users

PHP file upload with IIS on windows XP/2000 etc

Error: Length parameter must be greater than 0

Multiple File Upload in PHP using IFRAME

Resume or Pause File Uploads in PHP

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

Handling file locks in PHP

HTML table output using Nested for loops in PHP

Count occurrences of a character in a String in PHP

Archived Comments

1. I hope so.:d
View Tutorial          By: khoa at 2008-06-10 04:18:31

2. I an going to try this code.
View Tutorial          By: Bhagawati Prasad at 2010-02-06 02:45:10

3. Thanks,It's perfect solution,I solved my probleam
View Tutorial          By: Suryaprakash Raghuwanshi at 2009-07-04 19:06:24

4. This works great, just remember to add <uses-pe
View Tutorial          By: Nick at 2012-06-20 07:37:15

5. why push is error in st.push(new Integer(a)); ? an
View Tutorial          By: ann at 2015-02-02 09:23:41

6. superb superb maza aggaya maza aggaya
View Tutorial          By: pramodh at 2012-04-16 05:21:54

7. plz send java object class with examples
View Tutorial          By: naidu at 2009-07-18 00:00:16

8. DO NOT USE QSORT IN A C++ CODE.

If

View Tutorial          By: paercebal at 2008-08-13 05:06:45

9. to get out of time out at step 2 error i used to
View Tutorial          By: Niluk at 2014-06-04 05:58:03

10. thanks , but i want it some thing like fibonici se
View Tutorial          By: Arpit Agrawal at 2015-01-04 18:34:41