A full explanation of the programming language PHP
PHP programming language is a very powerful language used for programming and development of dynamic Web sites and interactive strongly stringent The beauty of the performance. The most common and widely used in the world of this language. It is also a contender for the alternative development languages such as Microsoft ASP.NET websites and other ..
Considered appropriate language for the development of Web sites where you can write your code out of HTML tags language are intertwined with it without any problems.
Which increases the splendor of this language and its proximity to programmers that its code is very close to writing other languages On Mattel C and PERL. It is worth to mention, it's open source language is free to use and is usually used with Apache surfer who work together on all operating systems Moreover, it is the language of PHP can work on your IIS for Microsoft and the Windows operating system.
Beginning:
It is the programming language PHP is very sophisticated languages as I mentioned earlier as a reminder to the beginning of learning HTML programming their use must first know .... or does not complement the lessons with us
MySQL is considered a user databases with PHP, for several reasons, notably the speed and lightness and maintain data.
Beginning work with PHP:
To begin programming and applying the lessons using the language PHP you need to install the following programs:
1-surfer Apache apache server which can be downloaded for Windows or Linux without any problems and can be downloaded from the following link:
2. Download the language of PHP through the following link:
3. Download MySQL databases through the following link:
If you go to any page written in PHP and I went to the width of the source code, you will not find any letter written in PHP and all you'll find is some HTML tags are surprised and asks why
The reason for this is that the PHP language that is applied to the server and send the results to the browser, which in turn displays the HTML tags.
Before writing the code must be found within the code page php extension.
How to write PHP code:
PHP Code is a code that begins with php?> And ends with?>. As it can be located anywhere within the file based on the need for its existence.
php?>
<?
The PHP file is a file usually contains codes Merged with PHP and HTML tags can be through the following code to understand what I mean:
php?>
; "Echo" Hello World
<?
Each command in the language of the PHP code must end with a semicolon where they are used to separate and distinguish between orders and each other.
Of course we finished the way of writing code now and I'll be back after the completion of the work I'm doing to how to define variables
Changes in the programming language PHP
Today we will know by the definition of variables and how to use and handle.
It is no secret one ml of the variables of importance in any software code ... where is not free software code from a variable is used to store either a value or a number or text or to retrieve the value of the function or the other, and many others. So we should know how to define variables and handling.
When you select a variable, it can be used many times within the file.
To define a variable in the programming language PHP variable name must begin with a dollar sign $ .... must remember this well
The correct way to define a variable are as follows:
PHP Code:
$ Variable_name = value;
Programmers Alambtdan in the programming language PHP usually forget a dollar sign at the beginning of the variable definition. In this case, the variable Satabbar does not exist, so please pay attention.
Now we'll define two variables: one representing the text and the other represents a number and I see the difference:
PHP Code:
<? Php
$ Txt = "Hello World!" ;
$ Number = 16
?>
PHP programming language that does not need to define the variable type, where you can define a variable wherever you want as you do not have to define its kind. As we have seen in the previous example, we have the definition of a variable without specifying its type.
The language of the PHP select variable type based on the data contained in it automatically, unlike other programming languages such as Java where they are required to declare the variable type and determine the initial value for him.
PHP is in the variable definition and its kind when it is used for the first time.
Rules are defined variable names:
- Variable name must begin with a letter or lower _ the police. "
- Variable name can only contain letters, numbers, and the underscore and no use of special symbols.
- Can not be the variable name contains spaces at all.
Strings in PHP: String
It is used to define the variables that contain characters or symbols and other special strings.
Through this lesson, we will define the most commonly used functions in dealing with the strings in the language of PHP.
After we created a variable we will now define how to deal with him where he can deal with it directly or through a function.
In the following example will set the Hello World sentence and stored in the variable $ txt
PHP Code:
<? Php
$ Txt = "Hello World";
echo $ txt;
?>
Output will be the implementation of the previous code is as follows:
Hello World
Linkage between two emblematic:
We may need in some cases to display two series emblematic as if they were a single string and this shall be the presence of linkage between them is done as in the following example:
PHP Code:
<? Php
$ Txt1 = "Hello World";
$ Txt2 = "1234";
echo $ txt1. "." $ The txt2; ?>
The implementation will be output as follows:
Hello World 1234
If you look at the previous code and its result, we will find that we used the point of connection between two variables and put distance between them using quotation marks .... Please example application to see how things are going here.
Use strlen () function to determine the length of the text:
This function is used in order to know the length of the text or the series Avatar .. This is done by example as follows:
PHP Code:
<? Php
echo strlen ( "Hello world!");
?>
It will be the result of the application of the previous code is the number 12 where he expresses the length of the series Avatar The count includes our spaces.
Use strpos () function:
This function is used so as to learn a specific word present site during the series Avatar and starts the count of the number zero and the following example illustrates this thing where we want to know the word World site:
PHP Code:
<? Php
echo strpos ( "Hello world!", "world");
?>
This result will be displayed is the code number 6 in terms of location 6 is the beginning of the word World
In this lesson, I will explain in the programming language PHP processes that will be illustrated by the following tables:
Mathematical operations
the operation
the description
Example
Example
+
add
x = 2
x + 2
4
-
IPO
x = 2
5-x
3
*
beating
x = 4
x * 5
20
/
division
15/5
5/2
3
2.5
%
Modulus
5% 2
10% 8
10% 2
1
2
0
++
the increase
x = 5
x ++
x = 6
-
Decreases
x = 5
x--
x = 4
Operations set a specific value for the variable
the operation
Example
Exactly the same as a result of the following
=
x = y
x = y
+ =
x + = y
x = x + y
- =
x- = y
x = x-y
* =
x * = y
x = x * y
/ =
x / = y
x = x / y
. =
x. = y
x = x.y
% =
x% = y
x = x% y
Comparisons
the operation
the description
Example
==
Equal
5 == 8 returns the value false
! =
is not equal
5! = 8 returns true value
>
Greater than
5> 8 returns the value false
<
Younger than
5 <8 returns true value
> =
Greater than or equal
5> = 8 returns a false value
<=
Smaller than or equal to
5 <= 8 returns true value
Boolean operations
the operation
the description
Example
&&
And
x = 6
y = 3
(X <10 && y> 1) returns the value true
||
or
x = 6
y = 3
(X == 5 || y == 5) returns the value false
!
No
x = 6
y = 3
! (X == y) returns true value
The end of the lesson for this I think it is clear and simple and Mhkouran all to follow