Basics of php part1<br />Author –Subhasis Nayak<br />4/8/2010<br />1<br />
Why $php ?<br />Hi! Friends the day has gone when we designed our website with only  html.On those days internet is used f...
$Continue ....<br />Oh ! Yes you may ask me, why we choose php rather choosing a language like jsp,asp or etc.<br />Answer...
$Code dissection <br />Well just below there is a line of php code. In this code first and last part is most. Which tells ...
$Variables<br />It is the symbolic representation of the value. As the name suggest it can change over time. It can contai...
$Continue ....<br />In php we are not using type of value it is going to be store a like other programming lanuage. So we ...
4/8/2010<br />7<br />Copy right of - Subhasis Nayak<br />$Valide variables.<br />Php itself used this type<br />You might ...
$How to use variables ?<br />Examples of the naming variables: - $employee_name<br />4/8/2010<br />8<br />Copy right of - ...
Explanation of program <br /><?php?> - these two are php strat and end tags. All codes must be inside of this to run else ...
4/8/2010<br />Copy right of - Subhasis Nayak<br />10<br /><ul><li>On left hand side i just put a value ‘100’ to variable n...
Here we display the value then we assign another value and display it. Go to my blog for downloading the source code for t...
4/8/2010<br />Copy right of - Subhasis Nayak<br />11<br /><ul><li>You must dwonload the program casesensitivity.php and ru...
$numbers in php<br />We can do math works as we do in other programming language. Let’s check some example.<br />4/8/2010<...
$floating point numbers<br />We can work with floating point number a in other programming languages. Be careful there is ...
$strings in php <br />In PHP we can use strings in a different ways.<br />We can print a whole string with the help of ech...
Contineue .... <br />We can assign the a string to a variable as like below.<br />Example: - $my_string =”Hi, Do you know,...
$string functions<br />There are a lot of predefined string functions in PHP. We can collect the information about them fr...
Continue ....<br />Lowercase and uppercase-<br />4/8/2010<br />17<br />Copy right of - Subhasis Nayak<br />$mystring = “I ...
Continue ....<br />Uppercase of first character  of the sentence. <br />Upper casing the first character of each word .<br...
Upcoming SlideShare
Loading in …5
×

Php Basic Part1

2,278 views

Published on

in this presentation i try to explain basic fundamentals of php.

Published in: Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,278
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
64
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Php Basic Part1

  1. 1. Basics of php part1<br />Author –Subhasis Nayak<br />4/8/2010<br />1<br />
  2. 2. Why $php ?<br />Hi! Friends the day has gone when we designed our website with only html.On those days internet is used for only collect information. But now a days we are in web2.0 world of internet.<br />Now a days each and every one is on internet. Each one is socializing him selves.More and more companies coming to internet world to sell products or stay with their customers.<br />So we can not stay with html to provide a high end site like facebook.com , youtube.com, ebay.com, blogger.com,ibibo.com and etc.<br />4/8/2010<br />2<br />Copy right of - Subhasis Nayak<br />
  3. 3. $Continue ....<br />Oh ! Yes you may ask me, why we choose php rather choosing a language like jsp,asp or etc.<br />Answer is very simple .PHP is open source and easily compatable with the cheaper and secured database like MYSQL.<br />Next is more than 70% web site owner choosing php,mysql server due to the less price and high end performance.<br />4/8/2010<br />3<br />Copy right of - Subhasis Nayak<br />
  4. 4. $Code dissection <br />Well just below there is a line of php code. In this code first and last part is most. Which tells the web server to start and end of php block or code. You must write any php code inside the php block else you will get errors.<br />4/8/2010<br />4<br />Copy right of - Subhasis Nayak<br /><?php echo “Welcome to PHP programming” ;?><br />
  5. 5. $Variables<br />It is the symbolic representation of the value. As the name suggest it can change over time. It can contain.In PHP it has some sort of rules for variable naming as follows.<br />It must start with a dollar sign<br />Followed by a letter, under score <br />It must not contain any space else php will think it as a different entity.<br />It can contain letters, numbers, underscores or dashes.<br />It is case sensitive.<br />4/8/2010<br />5<br />Copy right of - Subhasis Nayak<br />
  6. 6. $Continue ....<br />In php we are not using type of value it is going to be store a like other programming lanuage. So we just use a dollar sign ”$” and variable name. When we store a value it automatically detects the type and works on it. Declaration and value assigning in php as below.<br />$urname,$ur_name,$Urname - (declaring a variable) <br />$urname = “Subhasis Nayak”;<br />$age = 25;<br />4/8/2010<br />6<br />Copy right of - Subhasis Nayak<br />
  7. 7. 4/8/2010<br />7<br />Copy right of - Subhasis Nayak<br />$Valide variables.<br />Php itself used this type<br />You might confused with subtraction sign<br />You might confused with number of dashes<br />
  8. 8. $How to use variables ?<br />Examples of the naming variables: - $employee_name<br />4/8/2010<br />8<br />Copy right of - Subhasis Nayak<br /><?php<br />$myvariable = 200;<br />echo $myvariable;<br />$myVariable =”Welcome to Nayak world”;<br />echo $myVariable;<br />$myvariable=500;<br />echo $myvariable; <br />?><br />
  9. 9. Explanation of program <br /><?php?> - these two are php strat and end tags. All codes must be inside of this to run else we will get errors.<br />4/8/2010<br />9<br />Copy right of - Subhasis Nayak<br />$myvariable = 200;<br />$myVariable =”Welcome to Nayak world”;<br />$myvariable=500;<br />Variables with values<br />Displays the value of the variavle<br />echo $myvariable;<br />
  10. 10. 4/8/2010<br />Copy right of - Subhasis Nayak<br />10<br /><ul><li>On left hand side i just put a value ‘100’ to variable name $myVar. Once here we asign the value w can echo(display) or use it. Here we can put another value to variable $myVar.
  11. 11. Here we display the value then we assign another value and display it. Go to my blog for downloading the source code for this program.</li></ul>Using variable<br /><?php<br />$my Var = 100;<br />echo ”value on variable ” .$myVar. ”</br>”;<br />$my Var = 500;<br />echo ”value on variable ” .$myVar. ”</br>”;<br />?><br />
  12. 12. 4/8/2010<br />Copy right of - Subhasis Nayak<br />11<br /><ul><li>You must dwonload the program casesensitivity.php and run it. Tell me what you will find. Put the answer as comment just below the post. I will check reply you the answer why it is so. If you get that why so? Then comment it.</li></ul>Case sensitivity<br /><?php<br />$my Var = 100;<br />echo ”value on variable ”.$myVar. ”</br>”;<br />$my Var = 500;<br />echo ”value on variable ” .$myvar. ”</br>”;<br />?><br />
  13. 13. $numbers in php<br />We can do math works as we do in other programming language. Let’s check some example.<br />4/8/2010<br />12<br />Copy right of - Subhasis Nayak<br />$mynumber =10;<br />$mynumber +=10; ans=20<br />$mynumber -=10; ans=10<br />$mynumber *=10; ans=100<br />$mynumber /=10; ans=10<br />Increment &decrement:-<br />$mynumber++ <br />$mynumber- -<br />
  14. 14. $floating point numbers<br />We can work with floating point number a in other programming languages. Be careful there is nothing special to create a floating point in PHP. Some of them are as below.<br />Rounding up the floating point:-<br />4/8/2010<br />13<br />Copy right of - Subhasis Nayak<br />$varfloat =3.14;<br />echo 12/5;<br />Round($varfloat,1); ans=3.1 (rounded one decimal point)<br />Ceil($varfloat); ans=4 (it rouned up tp next integer)<br />Floor($varfloat); ans=3 (it rounds up previous integer)<br />
  15. 15. $strings in php <br />In PHP we can use strings in a different ways.<br />We can print a whole string with the help of echo and double quote (“”) as below<br />Example: - echo “Welcome to PHP world”;<br />We can print a whole string with the help of echo and single quote (‘’) as below<br />Example:- echo ‘welcome to the drupal’;<br />4/8/2010<br />14<br />Copy right of - Subhasis Nayak<br />
  16. 16. Contineue .... <br />We can assign the a string to a variable as like below.<br />Example: - $my_string =”Hi, Do you know, Joomla is very powerful”;<br />can do concatenations like below.<br />Example: - echo $my_variable. “wow!”;<br />We can print a string with a variable combinedly as below.<br />Example: - echo $my_string. ” a CMS”;<br />4/8/2010<br />15<br />Copy right of - Subhasis Nayak<br />
  17. 17. $string functions<br />There are a lot of predefined string functions in PHP. We can collect the information about them from http://php.net . some of them as below<br />Concatenation – <br />Example:- $my_string1=”HI! Good morning”;<br />4/8/2010<br />16<br />Copy right of - Subhasis Nayak<br />$my_string1=”HI! Good morning”;<br />$my_string2=” and have a nice day”;<br />$my_string3=$my_string1;<br />$my_string3 .=$mys_tring2 ;<br />echo $my_string3;<br />
  18. 18. Continue ....<br />Lowercase and uppercase-<br />4/8/2010<br />17<br />Copy right of - Subhasis Nayak<br />$mystring = “I AM A PROGRAMMING ROBOT”;<br />$my_lower = strtolower($mystring);<br />echo $my_lower;<br />$mystring =“programming is my hobby”;<br />$my_upper = strtoupper ($mystring);<br />echo $my_upper;<br />
  19. 19. Continue ....<br />Uppercase of first character of the sentence. <br />Upper casing the first character of each word .<br />4/8/2010<br />18<br />Copy right of - Subhasis Nayak<br />$my_string1 = “hello! Mr. Guest”;<br />$my_str = ucfirst($my_string1);<br />echo $my_str;<br />$my_string2 = “hello! Mr. Someone”;<br />$my_lower = ucwords($my_string2);<br />echo $my_str;<br />
  20. 20. $ Meet you on next session<br />On next session We will disscuss on<br />Arrays and arrays functions<br />Type casting<br />Constants<br />Control structures<br />4/8/2010<br />19<br />Copy right of - Subhasis Nayak<br />Thank you<br />Till then bye bye.<br />

×