php: the easiest language to learn
TRANSCRIPT
- 1. PHP
- The easiest language to learn.
- By Binny V A
- http://www.bin-co.com/php/
- 2. PHP P HP:H ypertextP 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. LAMP Linux/Apache/MySQL/PHP
- 5. Hello World!
- php file.php
- firefox http://localhost/file.php
- 6. 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
- 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+2Plus
- -5-2Minus
- *
- /
- ==1 == true
- ===1 !== true
- !=
- %Mod
- =$a = 5
- .hel . lo
- etc.
- 9. Control Flow: if If 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 PHP
- PHP 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 PHP Manual(CHM) Install KCHM to view it.
- 16. Functions
- String Functions
- strtolower() / strtoupper()
- str_replace()
- strpos()
- Array Functions
- array()
- count()
- array_push()
- array_splice()
- ...
- 17. Database
- MySQL must be 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 the Web Embedding PHP...
- 22. Form Submission Age:
- 23. action.php if($_POST['action'] == 'Save') { print $_POST['age']; }
- 24. Frameworks
- Zend
- CodeIgnite
- CakePHP
- Symphony
- And more..
- 25. Free Software
- CMS Tools
-
- 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/