Php1
Upcoming SlideShare
Loading in...5
×
 

Php1

on

  • 1,651 views

 

Statistics

Views

Total Views
1,651
Views on SlideShare
1,650
Embed Views
1

Actions

Likes
1
Downloads
65
Comments
0

1 Embed 1

http://www.slideshare.net 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

Php1 Php1 Presentation Transcript

  • PHP
      • PHP stands for P HP: H ypertext P reprocessor
      • PHP is a server-side scripting language, like ASP
      • PHP scripts are executed on the server
      • PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
      • PHP is an open source software
      • PHP is free to download and use
  • How PHP Works: When a user navigates her browser to a page that ends with a .php extension, the request is sent to a web server, which directs the request to the PHP interpreter. The PHP interpreter processes the page, communicating with file systems, databases, and email servers as necessary, and then delivers a web page to the web server to return to the browser.
  • PHP FILES
    • PHP files can contain text, HTML tags and scripts.
    • PHP files are returned to the browser as plain HTML. 
    • PHP files have a file extension of ".php", ".php3", or ".phtml"
    • PHP code is executed on the server, and the plain HTML result is sent to the browser.
    • A PHP file contains HTML tags and some PHP scripting code.
  • Basic PHP Syntax
    • A PHP scripting block always starts with
    • <?php and ends with ?>.
    • A PHP scripting block can be placed anywhere in the document.
    • On servers with shorthand support enabled us to start a scripting block with <? and end with ?>.
    • For maximum compatibility, it is recommended that to use the standard form ( <?php ) rather than the shorthand form.
      • Each code line in PHP must end with a semicolon .
      • The semicolon is a separator and is used to distinguish one set of instructions from another.
      • There are two basic statements to output text with PHP:
      • In the eg we have used the echo statement to output the text &quot;Hello World&quot;.
      • Note : The file must have a .php extension. If the file has a .html extension , the PHP code will not be executed.
    echo and print
  • Comments in PHP: In PHP, we use // to make a single-line comment or /* and */ to make a large comment block. <html><body> <?php -> Single-line Comment -> Large Comment ?> </body></html> //This is a comment /* This is a comment block */
  • VARIABLES IN PHP
      *Variables are used for storing information values, like text strings, numbers or arrays.
        *When a variable is declared, it can be used over and over again in your script. *All variables in PHP start with a $ sign symbol. *The correct way of declaring a variable in PHP :
    $var_name = value; EG: Creating a variable containing a string, and a variable containing a number: <?php $txt=&quot;Hello World!&quot;; $x=16; ?>
  • PHP . ini
    • PHP.ini is very useful and it is a configuration file that is used to customize behavior of PHP at runtime.
    • This enables easy administration in the way that administer Apache web server using configuration files.
    • The Settings in which upload directory, register global variables, display errors, log errors, max uploading size setting, maximum time to execute a script and other configurations is written in this file.
    • When PHP Server starts up it looks for PHP.ini file first to load various values for settings.
      • The configuration file (php.ini) is read when PHP starts up.
      • php.ini file controls many aspects of PHP's behavior.
      • In order for PHP to read it, it must be named 'php.ini'.
      • PHP looks for it in the current working directory, in the path designated by the environment variable.
      • The php.ini directives allows us to set configure our PHP setup.
  • The parse_ini_file() function parses a configuration (ini) file and returns the settings in it in an array. Syntax: parse_ini_file(file,process_sections) file Required. Specifies the ini file to check process_sections Optional. If set to TRUE, it returns is a multidimensional array with section names and settings included. Default is FALSE
  • This function can be used to read in your own application's configuration files, and has nothing to do with the php.ini file. The following reserved words must not be used as keys for ini files: null, yes, no, true, and false. There are also some reserved characters that must not be used in the keys: {}|&~![()&quot;. Contents of &quot;test.ini&quot;: [names] me = Robert you = Peter [urls] first = &quot;http://www.example.com&quot; second = &quot;http://www.w3schools.com&quot;
  • PHP code: <?php print_r(parse_ini_file(&quot;test.ini&quot;)); ?> The output of the code above will be: ( [me] => Robert [you] => Peter [first] => http://www.example.com [second] => http://www.w3schools.com )