All posts in PHP

Introduction to PHP – Part10

php-part10

Classes and Objects:

The programming paradigm we have learned so far is called Procedural Paradigm. In Procedural programming paradigm, programmer writes a program as collections of independently behaving procedures and makes use of procedure call to access those procedures. As we already discussed in Part8, how procedural programming is a better choice than a simple unstructured programming. It has been a long time, programmers have started thinking about new paradigm called Object oriented paradigm (OOP) which provides a better way to develop big and complex system than procedural programming. We don’t want to confuse readers by putting too complex terms and advantages of OOP at this stage, we will discuss when required. Read more…

Introduction to PHP – Part9

php-part9

Forms:

A form is an area where user can input data. The place in the form where user input data is called form element. A form element can be a text field, text area field, drop-down list, radio buttons and checkbox. In this tutorial we will apply the knowledge we have gained so far and use it with HTML forms. The best thing to use PHP with HTML is that any elements in HTML forms are directly available in PHP scripts. That means the data entered in HTML forms can be manipulated using PHP scripts. Read more…

Introduction to PHP – Part8

php-part8

Function:

A function is a subprogram that performs a specific task when called by the main program. It is always a good practice to divide a huge program into a number of subprograms until elementary functions are reached. More clearly, a huge program should be divided into number of functions, and a function precisely should do one job. Suppose, we have a big program that reads data from user at the beginning, save data to a database and displays the saved data at the end. Read more…

Introduction to PHP – Part7

php-part7

Array:

Array is a systematic collection of data of similar data types that can be accessed by numeric index. Array is one of the most important and oldest data structures that are used to implement other data structures like strings, maps, vector etc. An array in PHP is in fact an ordered map type that associates values to keys. We suggest readers to not get confused with map type here, simply understand PHP array as a data type that can be accessed using keys. Read more…

Introduction to PHP – Part6

php-part6

Strings:

A string is an array of characters. This tutorial demonstrates the use of string to manipulate text. A string can be represented in one of the following four ways; single quoted, double quoted, heredoc syntax and nowdoc syntax. Before describing each string in detail, it would be appropriate to discuss about escape sequence. Escape sequence are used to format the output text and other output options. Read more…

Introduction to PHP – Part 5

php-part5

Loops

A loop is a programming construct that facilitates programmer to execute some code number of times or a specified condition is true. For instance, we need to read a file stored in computer and print it in screen. Suppose the function available to read a file reads one line at a time and the file contains many lines, we have to write the same line of code many times to read one line at a time from the file.  By using loops we can execute the same code number of times called iterations to read the whole file, one line at a time until there is no line left in the file. Read more…

Introduction to PHP – Part4

php-part4

Control Statements

A program is a collection of modules working together to perform certain task. The modules can be thought independently which always produces the same set of output for a given set of input. Control statements control the execution of a program by executing those modules once at a time in a meaningful order,  known as flow of control. Basically, there are two types of control statements, branching statements and loops. In this tutorial, we will discuss branching statements in detail. Read more…

Introduction to PHP – Part 3

php-part3

Operators

An operator is a type of function which acts on operands often called inputs and produce results. In PHP, there are three types of operators. Increment operator ++ and decrement operator — belongs to the first operator group called unary operator. Unary operator always acts on single operand. The second group called the binary operator acts on more than two operands. . Read more…

Introduction to PHP – Part2

php-part2

Data Types:

PHP supports eight primitive types; four scalar types two compound and two special types. In this section we will discuss scalar types; boolean, integer, float and string. Other four array, object, resource and null will be discussed in the later sections.

Boolean:

 To define boolean variable we can specify TRUE or FALSE, both are case insensitive. The size of the Boolean variable is one byte. Read more…

Introduction to PHP – Part 1

php-part1

Introduction:

PHP is a widely used open source server side scripting language that is used to create dynamic and interactive web pages. PHP can be directly embedded into the HTML code and hence, is perfect for any web development. The syntax of PHP is very similar to Perl and C. PHP works on Apache web server and also supports Microsoft Internet Information Server. Read more…