• Like
Introductionto Php
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Introductionto Php

  • 3,870 views
Published

 

Published in Business , Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,870
On SlideShare
0
From Embeds
0
Number of Embeds
3

Actions

Shares
Downloads
164
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Introduction to PHP scripting language Lorenzo Tilve Álvaro
  • 2. List of topics
    • Basic concepts
    • Apache/CGI mode vs CLI
    • Installation & Configuration
    • Syntax
    • Web development with PHP
    • Security
    • Practices index
  • 3. 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
  • 4. Basic concepts
    • Main advantages:
      • Lightweight
      • Ease of use and administration
      • Multiple library support
      • Fast learning curve
      • Multiplatform
      • Provides a lot of connectors
  • 5. 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
  • 6. 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
  • 7. 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
  • 8. 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
  • 9. 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
  • 10. 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
  • 11. 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
  • 12. Configuration
    • Important configuration settings in php.ini :
        • safe_mode configuration
        • max_execution_time & memory_limit
        • register_globals
        • logging directories
  • 13. Syntax
    • PHP code structure
      • Basic syntax
      • Types, variables and Constants
      • Expressions
      • Operators
      • Control Structures
      • Functions
  • 14. Syntax
    • Basic syntax
      • PHP script
        • <?php
        • echo “This is a php file: ”;
        • // Online comment
        • ?>
      • HTML embed
        • <body>
        • <? phpinfo(); /* This is a comment */ ?>
        • </body>
  • 15. 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; );
  • 16. 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;
  • 17. Syntax
    • Conditions
        • $user_id = 'login';
        • $ban_list = array( ) ;
        • // && and, || or, == equal operators
        • if ( empty( $user_id ) || in_array( $user_$ban_list ) )
        • {
        • exit( );
        • }
  • 18. Syntax
    • Looping
        • $elements = array( “one”, “two”, “three”);
        • // Foreach, while and for loops
        • foreach ( $elements as $value ) {
        • $results[ ] = $value. &quot;processed&quot;;
        • }
  • 19. 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;
        • }
  • 20. 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;
  • 21. 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
  • 22. Web development
    • Processing HTTP variables
      • Cookies and session handling
    • Connector for system integration
      • Web services using nusoap
      • Database handling
      • Image management
      • LDAP, Mail, etc, ...
  • 23. Practices
    • Introductory practices
      • Basic PHP syntax and CLI mode
      • Configuration and security
      • Database and filesystem interaction
      • Data processing and sending mail
  • 24. Teachers
    • Lorenzo Tilve. Igalia
      • Engineering group.
      • [email_address]
    • Xavier Castaño. Igalia
      • Engineering group.
      • [email_address]