KEMBAR78
PHP: The easiest language to learn. | ODP
PHP The easiest language to learn. By Binny V A http://www.bin-co.com/php/
PHP P HP:  H ypertext  P reprocessor PHP: Hypertext Preprocessor PHP: Hypertext Preprocessor PHP: Hypertext Preprocessor PHP: ... Like GNU.
Its Easy – but Hard To use PHP, you must know... HTML SQL CSS JavaScript Web Server(Apache) Configuration Database Server(MySQL) Configuration
LAMP Linux/Apache/MySQL/PHP
Hello World! <?php print “Hello World”; ?> php file.php firefox http://localhost/file.php
Variables $ Prefix for variables $name =  'ILUG' ; // String $year =  2008 ; // Number $is_php_good =  true ; // Boolean // is a comment – as is /* to */ - PHP follows the C Syntax
Arrays/Hashes $arr = array(“Indian”, “Linux”, “User”, “Group”); $arr[1] = 'Libre'; print $arr[1]; $details = array( “abbr” => “ILUG”, “full” => “Indian Libre User Group” ); print $details['full'];
Operators +  5+2  Plus -  5-2  Minus * / ==  1 == true ===  1 !== true != %  Mod =  $a = 5 .  “hel” . “lo” etc.
Control Flow: if If if($name == 'Binny') { print “Hi, Binny”; } elseif($name == 'Sameer') { print “Hello Sameer”; } else { print “Hello everybody”; }
For/Foreach For $languages = array('PHP', 'Ruby', 'JavaScript', 'Python', 'Perl', 'Tcl'); for($i =0; $i < count($languages); $i++) { print $i+1 . “) “ . $languages[$i]; } Foreach foreach($languages as $lang) { print $lang; }
While Loop $i = 1; While($i < 10) { print $i; $i++; }
Functions function hello($name) { print “Hello, $name.”; } hello(“World”);
OOPs and PHP PHP 5 has all the most necessary OOPs features... Constructors/Destructors Visibility (public, private, protected) Static Methods/Variables Abstraction Inheritance And more...
Class class Movie { public $name; function __construct($movie_name) { $this->name = $movie_name; } function show() { print $this->name; } } $film = new Movie(“City of God”); $film->show();
Getting Help PHP Manual(CHM) Install KCHM to view it.
Functions String Functions strtolower() / strtoupper() str_replace() strpos() Array Functions array() count() array_push() array_splice() ...
Database MySQL must be installed and running. Need Information about... server(usually 'localhost') username password database
Connection mysql_connect('localhost', 'root', 'password'); mysql_select_db('database_name'); Use a database abstraction layer. $db = new Sql(“localhost”, 'root', 'password', 'database_name');
Executing Queries  $sql_handle = mysql_query(“SELECT id,name FROM users WHERE status='1'”)  or die(mysql_error()); $result = mysql_fetch_assoc($sql_handle); print $result['name'];
Fetching Result while($result = mysql_fetch_assoc($sql_handle)) { print $result['name']; } Use Database Abstraction layer!
PHP and the Web Embedding PHP... <strong><?php print hello($name) ?></strong>
Form Submission <form action=”action.php” method=”post”> Age: <input type=”text” name=”age” /> <input type=”submit” name=”action” value=”Save” /> </form>
action.php if($_POST['action'] == 'Save') { print $_POST['age']; }
Frameworks Zend CodeIgnite CakePHP Symphony And more..
Free Software CMS Tools WordPress Drupal Joomla/Mambo Forum phpBB BbPress Shopping Cart Wiki
Credits Getting Help:  http://www.flickr.com/photos/doctorow/2496308570/ MySql:  http://www.flickr.com/photos/johnniewalker/359440369/ Framework Image :  http://www.sxc.hu/photo/916787 Free Software:  http://www.flickr.com/photos/marcomolinari_it/2474783234/

PHP: The easiest language to learn.

  • 1.
    PHP The easiestlanguage to learn. By Binny V A http://www.bin-co.com/php/
  • 2.
    PHP P HP: H ypertext P reprocessor PHP: Hypertext Preprocessor PHP: Hypertext Preprocessor PHP: Hypertext Preprocessor PHP: ... Like GNU.
  • 3.
    Its Easy –but Hard To use PHP, you must know... HTML SQL CSS JavaScript Web Server(Apache) Configuration Database Server(MySQL) Configuration
  • 4.
  • 5.
    Hello World! <?phpprint “Hello World”; ?> php file.php firefox http://localhost/file.php
  • 6.
    Variables $ Prefixfor variables $name = 'ILUG' ; // String $year = 2008 ; // Number $is_php_good = true ; // Boolean // is a comment – as is /* to */ - PHP follows the C Syntax
  • 7.
    Arrays/Hashes $arr =array(“Indian”, “Linux”, “User”, “Group”); $arr[1] = 'Libre'; print $arr[1]; $details = array( “abbr” => “ILUG”, “full” => “Indian Libre User Group” ); print $details['full'];
  • 8.
    Operators + 5+2 Plus - 5-2 Minus * / == 1 == true === 1 !== true != % Mod = $a = 5 . “hel” . “lo” etc.
  • 9.
    Control Flow: ifIf if($name == 'Binny') { print “Hi, Binny”; } elseif($name == 'Sameer') { print “Hello Sameer”; } else { print “Hello everybody”; }
  • 10.
    For/Foreach For $languages= array('PHP', 'Ruby', 'JavaScript', 'Python', 'Perl', 'Tcl'); for($i =0; $i < count($languages); $i++) { print $i+1 . “) “ . $languages[$i]; } Foreach foreach($languages as $lang) { print $lang; }
  • 11.
    While Loop $i= 1; While($i < 10) { print $i; $i++; }
  • 12.
    Functions function hello($name){ print “Hello, $name.”; } hello(“World”);
  • 13.
    OOPs and PHPPHP 5 has all the most necessary OOPs features... Constructors/Destructors Visibility (public, private, protected) Static Methods/Variables Abstraction Inheritance And more...
  • 14.
    Class class Movie{ public $name; function __construct($movie_name) { $this->name = $movie_name; } function show() { print $this->name; } } $film = new Movie(“City of God”); $film->show();
  • 15.
    Getting Help PHPManual(CHM) Install KCHM to view it.
  • 16.
    Functions String Functionsstrtolower() / strtoupper() str_replace() strpos() Array Functions array() count() array_push() array_splice() ...
  • 17.
    Database MySQL mustbe installed and running. Need Information about... server(usually 'localhost') username password database
  • 18.
    Connection mysql_connect('localhost', 'root','password'); mysql_select_db('database_name'); Use a database abstraction layer. $db = new Sql(“localhost”, 'root', 'password', 'database_name');
  • 19.
    Executing Queries $sql_handle = mysql_query(“SELECT id,name FROM users WHERE status='1'”) or die(mysql_error()); $result = mysql_fetch_assoc($sql_handle); print $result['name'];
  • 20.
    Fetching Result while($result= mysql_fetch_assoc($sql_handle)) { print $result['name']; } Use Database Abstraction layer!
  • 21.
    PHP and theWeb Embedding PHP... <strong><?php print hello($name) ?></strong>
  • 22.
    Form Submission <formaction=”action.php” method=”post”> Age: <input type=”text” name=”age” /> <input type=”submit” name=”action” value=”Save” /> </form>
  • 23.
    action.php if($_POST['action'] =='Save') { print $_POST['age']; }
  • 24.
    Frameworks Zend CodeIgniteCakePHP Symphony And more..
  • 25.
    Free Software CMSTools WordPress Drupal Joomla/Mambo Forum phpBB BbPress Shopping Cart Wiki
  • 26.
    Credits Getting Help: http://www.flickr.com/photos/doctorow/2496308570/ MySql: http://www.flickr.com/photos/johnniewalker/359440369/ Framework Image : http://www.sxc.hu/photo/916787 Free Software: http://www.flickr.com/photos/marcomolinari_it/2474783234/