Friday, February 8, 2008

Welcome to PHP world

In the name of Allah

this is the second but it should be the third series on this blog but my friend adel is some kind late
so we will start learning php from installing to ...... as far as the author of the book go
first : installation
there are a hundreds of ways i choose the easiest one just go to http://sourceforge.net/projects/quickeasyphp/
and download easyphp then install it , congratulation u finished the first step
it works good for windows i don't know what about Linux
for the setup for Linux just contact me
after installation you will find an icon behind the clock right click on it choose local web it will open ur browser with a page have the files u have in folder www this folder located in C:\Program Files\EasyPHP 2.0b1\www but it depend on where u installed the easyphp so any file u make and want to test u move it to the www folder and open it from local web
second : introduction to php
now lest talk about php its the most powerful scripting language it's free , open scource ,and dynamic
in this series we will use php 5 and hope u make php 6
and we wont talk about just php alone but we will talk about AMP
Apache "Server" , Mysql "Database" , and the Php
it some kind like a restaurant the waiter is php , the chief is apache and it get the ingredients from mysql
third : start
u write the php code within the html code and name the file *.php or *.html but using easyphp it just work with *.PHP
let's see an example
< html>< body>
< ?php
echo "that's my first page ";
?>
< /body>< /html>
first just open the php tag and after u finish u close it
and remmber to end ur statment with semicolon
u can open it more than one time and u can use html inside the tag of php
like this
< ?php
echo "< h1>hello< /h1 >";
echo "< h2>bye< /h2 >";
?>
echo is used to print some thing like text or variables or html tags
like this
echo "< br/>"; to make a new line
Constants :
its like constants any where u make it define it cant change it again but can reuse it print it
define(); is builtin function to make contants
it take arguments the constant name and it's value
like
define("year","1998");
year is constant and its value is 1998
Variables:
it start with $ and you can make it give it a value and reset it change it's value call it or display and without declaration
u can do any thing with it like
$year=1998;
here u make a variable and give it a value
in php 5 all variables passed by reference
some built in function:
rand(min,max); it takes 2 values and give a random number between them
ceil(number); it take a number and round a decimal up to the next highest integer
floor(number); it take a number and round a decimal down to the next lowest integer
number_format(number,number,separator,separator);
it can take 1 , 2 ,or 4 parameters "no 3 parameters"
one parameter it separate the thousand with a comma and round the decimal
12345.23->12,345
two parameters it take the number and the number of digit after the decimal point
number_format(1234.4,3); ->1234.400
four parameters they are( number , the number of digits after the decimal point , the separator sign for the thousands and the separator sign for the float)
max(n,n1,n1,.....); return the maximum
min(n,n1,n1,..... ); return the minimum
and the next episode we will talk about passing variable between pages

2 comments:

Uniqe said...

thx my friend

soli said...

congratulations Mahmoud for your great kick start.
we are waiting for more, keep on .