Introductionto Php
Upcoming SlideShare
Loading in...5
×
 

Introductionto Php

on

  • 4,444 views

 

Statistics

Views

Total Views
4,444
Views on SlideShare
4,106
Embed Views
338

Actions

Likes
2
Downloads
163
Comments
0

4 Embeds 338

http://warunglobak.blogspot.com 318
http://jaypeeworldprogrammer.blogspot.com 18
http://www.jaypeeworldprogrammer.blogspot.com 1
http://warunglobak.blogspot.sg 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Introductionto Php Introductionto Php Presentation Transcript

  • Introduction to PHP scripting language Lorenzo Tilve Álvaro
  • List of topics
    • Basic concepts
    • Apache/CGI mode vs CLI
    • Installation & Configuration
    • Syntax
    • Web development with PHP
    • Security
    • Practices index
  • Basic concepts
    • PHP ( PHP Hypertext Preprocessor ) was born in 1994
    • Reference documentation
      • http://www.php.net
      • http://www.php.net/manual/en/langref.php
    • Characteristics:
      • Interpreted language
      • Implicit variable declaration
      • PHP stack
  • Basic concepts
    • Main advantages:
      • Lightweight
      • Ease of use and administration
      • Multiple library support
      • Fast learning curve
      • Multiplatform
      • Provides a lot of connectors
  • Basic concepts
    • Some disadvantages:
      • Complexity to handle large session data
      • Upgrade problems:
        • Issues with backwards compatibility
        • Certain package dependences
      • Lack of debugging tools
      • Handling of balance load
  • Basic concepts
    • Current releases state (Feb 08):
      • Stable branch 5.2.5
      • Compatibility support 4.4.8
    • Migration information
      • www.php.net/manual/en/migration5.php
    • Road to PHP 6
  • Apache/CGI mode vs CLI
    • PHP as a scripting language
    • Embed integration with HTML and use of templates
    • Programmed scripting process via cronjobs
    • Separated configuration files for different scenarios
  • Apache/CGI mode vs CLI
    • In CGI mode all PHP stack is regenerated with each request
      • Necessity of usage of GET, POST and SESSION variables to communication between requests
      • Cookie and user agent management
      • Alternatives for other technological components integration
  • Installation & Configuration
    • PHP multiplatform packages
      • Bundled packages of Apache+Mysql+PHP environment
      • For Ubuntu / Debian distributions
        • apt-get install php5 php5-common php5-cli
    • Specific compilation instructions
      • http://es.php.net/manual/en/install.unix.php
  • Configuration
    • Other important libraries:
        • php5-imap: IMAP module for php5
        • php5-ldap: LDAP module for php5
        • php5-mcrypt: MCRYPT module for php5
        • php5-mysql: MySQL module for php5
        • php5-gd: GD module for php5
        • php5-pear: PEAR - PHP Extension and Application
        • ...
    • PHP accelerator
      • Zend extension
  • Configuration
    • Configuration files
      • /etc/php5/cli/etc.ini
      • /etc/php5/apache2/etc.ini
      • /etc/php5/cgi/etc.ini
    • For Apache usage
      • Apache configuration and virtualhosts setup with php_value directives
  • Configuration
    • Important configuration settings in php.ini :
        • safe_mode configuration
        • max_execution_time & memory_limit
        • register_globals
        • logging directories
  • Syntax
    • PHP code structure
      • Basic syntax
      • Types, variables and Constants
      • Expressions
      • Operators
      • Control Structures
      • Functions
  • Syntax
    • Basic syntax
      • PHP script
        • <?php
        • echo “This is a php file: ”;
        • // Online comment
        • ?>
      • HTML embed
        • <body>
        • <? phpinfo(); /* This is a comment */ ?>
        • </body>
  • Syntax
    • Types, variables and Constants
        • // Constat declaration
        • define( &quot;STRING_MAX_LENGTH&quot;, 25);
        • define( &quot;USER&quot;, 1 );
        • define( &quot;USER_GROUP&quot;, 2 );
        • define( &quot;STANDARD_USER&quot;, &quot;user&quot; );
        • define( &quot;ADMIN_USER&quot;, &quot;admin&quot; );
  • Syntax
    • Types, variables and Constants
        • // Arrays
        • $array = array( 'item1', 'item2', 'item3' );
        • $array2 = array( 'u1'=>'item1', 'u2'=>'item2' );
        • $arra2['u3'] = 'item3';
        • // Strings
        • $string = 'This is a string';
        • $string2 = &quot;This is another string and $string&quot;;
        • $string3 = $string . &quot; and &quot; . $string2;
  • Syntax
    • Conditions
        • $user_id = 'login';
        • $ban_list = array( ) ;
        • // && and, || or, == equal operators
        • if ( empty( $user_id ) || in_array( $user_$ban_list ) )
        • {
        • exit( );
        • }
  • Syntax
    • Looping
        • $elements = array( “one”, “two”, “three”);
        • // Foreach, while and for loops
        • foreach ( $elements as $value ) {
        • $results[ ] = $value. &quot;processed&quot;;
        • }
  • Syntax
    • Functions
        • // File requirements and inclussions
        • require_once(“myclass.php”);
        • include_once(“myclass.php”);
        • // Declaration
        • function foo ( $param1, $param2 = def_value, ...) {
        • // do some stuff
        • return $value;
        • }
  • Security
    • Safe mode
      • Limits execution of server-owned scriptsa and safe_mode_include_dir binaries
    • Register globals
    • Server validation
      • Unsafe client-side validation ( Javascript )
      • Filter SQL-injections
        • $id = mysql_real_escape_string($_POST['input']);
        • $SQL = 'SELECT * FROM table WHERE id = ' . $id;
  • Web development
    • PHP is extremely popular for CMS development on LAMP environments.
      • Typo3, eZPublish, Joomla, Drupal, phpNuke, Mambo, ...
      • www.cmsmatrix.com
    • Original web approach vs. specific PHP pages with presentation templates:
      • Model–View–Controller design pattern
  • Web development
    • Processing HTTP variables
      • Cookies and session handling
    • Connector for system integration
      • Web services using nusoap
      • Database handling
      • Image management
      • LDAP, Mail, etc, ...
  • Practices
    • Introductory practices
      • Basic PHP syntax and CLI mode
      • Configuration and security
      • Database and filesystem interaction
      • Data processing and sending mail
  • Teachers
    • Lorenzo Tilve. Igalia
      • Engineering group.
      • [email_address]
    • Xavier Castaño. Igalia
      • Engineering group.
      • [email_address]