PHP Operators
Operators are used to operate on values.
PHP Operators
This section lists the different operators used in PHP.
Arithmetic Operators
Operator Description Example Result
+ Addition x=2
x+2 4
- Subtraction x=2
5-x 3
* Multiplication x=4
x*5 20
/ Division 15/5
5/2 3
2.5
% Modulus (division remainder) 5%2
10%8
10%2 1
2
0
++ Increment x=5
x++ x=6
-- Decrement x=5
x-- x=4
Assignment Operators
Operator Example Is The Same As
= 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
Comparison Operators
Operator Description Example
== is equal to 5==8 returns false
!= is not equal 5!=8 returns true
> is greater than 5>8 returns false
< is less than 5<8 returns true
>= is greater than or equal to 5>=8 returns false
<= is less than or equal to 5<=8 returns true
Logical Operators
Operator Description Example
&& and x=6
y=3
(x < 10 && y > 1) returns true
|| or x=6
y=3
(x==5 || y==5) returns false
! not x=6
y=3
!(x==y) returns true
Read More...
PHP Installation
What do You Need?
This tutorial will not explain how to install PHP, MySQL, or Apache Server.
If your server supports PHP - you don't need to do anything! You do not need to compile anything or install any extra tools - just create some .php files in your web directory - and the server will parse them for you. Most web hosts offer PHP support.
However, if your server does not support PHP, you must install PHP. Below is a link to a good tutorial from Webmonkey on how to install PHP4:
http://hotwired.lycos.com/webmonkey/00/44/index4a.html?tw=programming
Download PHP
Download PHP for free here: http://www.php.net/downloads.php
Download MySQL Database
Download MySQL for free here: http://www.mysql.com/downloads/index.html
Download Apache Server
Download Apache for free here: http://httpd.apache.org/download.cgi
Read More...
Introduction to PHP
A PHP file may contain text, HTML tags and scripts. Scripts in a PHP file are executed on the server.
What you should already know
Before you continue you should have some basic understanding of the following:
WWW, HTML and the basics of building Web pages
Some scripting knowledge
What is PHP?
• PHP stands for PHP: Hypertext Preprocessor
• PHP is a server-side scripting language, like ASP
• PHP scripts are executed on the server
• PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
• PHP is an open source software (OSS)
• PHP is free to download and use
What is a PHP File?
• PHP files may contain text, HTML tags and scripts
• PHP files are returned to the browser as plain HTML
• PHP files have a file extension of ".php", ".php3", or ".phtml"
What is MySQL?
• MySQL is a small database server
• MySQL is ideal for small and medium applications
• MySQL supports standard SQL
• MySQL compiles on a number of platforms
• MySQL is free to download and use
PHP + MySQL
• PHP combined with MySQL are cross-platform (means that you can develop in Windows and serve on a Unix platform)
Why PHP?
• PHP runs on different platforms (Windows, Linux, Unix, etc.)
• PHP is compatible with almost all servers used today (Apache, IIS, etc.)
• PHP is FREE to download from the official PHP resource: www.php.net
• PHP is easy to learn and runs efficiently on the server side
Where to Start?
• Install an Apache server on a Windows or Linux machine
• Install PHP on a Windows or Linux machine
• Install MySQL on a Windows or Linux machine
Read More...
PHP Operators
Operators are used to operate on values.
PHP Operators
This section lists the different operators used in PHP.
Arithmetic Operators
Operator Description Example Result
+ Addition x=2
x+2 4
- Subtraction x=2
5-x 3
* Multiplication x=4
x*5 20
/ Division 15/5
5/2 3
2.5
% Modulus (division remainder) 5%2
10%8
10%2 1
2
0
++ Increment x=5
x++ x=6
-- Decrement x=5
x-- x=4
Assignment Operators
Operator Example Is The Same As
= 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
Comparison Operators
Operator Description Example
== is equal to 5==8 returns false
!= is not equal 5!=8 returns true
> is greater than 5>8 returns false
< is less than 5<8 returns true
>= is greater than or equal to 5>=8 returns false
<= is less than or equal to 5<=8 returns true
Logical Operators
Operator Description Example
&& and x=6
y=3
(x < 10 && y > 1) returns true
|| or x=6
y=3
(x==5 || y==5) returns false
! not x=6
y=3
!(x==y) returns true
Read More...
What do You Need?
This tutorial will not explain how to install PHP, MySQL, or Apache Server.
If your server supports PHP - you don't need to do anything! You do not need to compile anything or install any extra tools - just create some .php files in your web directory - and the server will parse them for you. Most web hosts offer PHP support.
However, if your server does not support PHP, you must install PHP. Below is a link to a good tutorial from Webmonkey on how to install PHP4:
http://hotwired.lycos.com/webmonkey/00/44/index4a.html?tw=programming
Download PHP
Download PHP for free here: http://www.php.net/downloads.php
Download MySQL Database
Download MySQL for free here: http://www.mysql.com/downloads/index.html
Download Apache Server
Download Apache for free here: http://httpd.apache.org/download.cgi
PHP Syntax
You cannot view the PHP source code by selecting "View source" in the browser - you will only see the output from the PHP file, which is plain HTML. This is because the scripts are executed on the server before the result is sent back to the browser.
A PHP file may contain text, HTML tags and scripts. Scripts in a PHP file are executed on the server.
What you should already know
Before you continue you should have some basic understanding of the following:
§ WWW, HTML and the basics of building Web pages
§ Some scripting knowledge
What is PHP?
· PHP stands for PHP: Hypertext Preprocessor
· PHP is a server-side scripting language, like ASP
· PHP scripts are executed on the server
· PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
· PHP is an open source software (OSS)
· PHP is free to download and use
What is a PHP File?
· PHP files may contain text, HTML tags and scripts
· PHP files are returned to the browser as plain HTML
· PHP files have a file extension of ".php", ".php3", or ".phtml"
What is MySQL?
· MySQL is a small database server
· MySQL is ideal for small and medium applications
· MySQL supports standard SQL
· MySQL compiles on a number of platforms
· MySQL is free to download and use
PHP + MySQL
· PHP combined with MySQL are cross-platform (means that you can develop in Windows and serve on a Unix platform)
Why PHP?
· PHP runs on different platforms (Windows, Linux, Unix, etc.)
· PHP is compatible with almost all servers used today (Apache, IIS, etc.)
· PHP is FREE to download from the official PHP resource: www.php.net
· PHP is easy to learn and runs efficiently on the server side
Where to Start?
· Install an Apache server on a Windows or Linux machine
· Install PHP on a Windows or Linux machine
· Install MySQL on a Windows or Linux machine