SlideShare uma empresa Scribd logo
1 de 25
PHP: Hypertext Preprocessor  PHP: Hypertext Preprocessor is a widely used, general-purpose scripting language that was originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document.
Usage: PHP is a general-purpose scripting language that is especially suited to server-side web development where PHP generally runs on a web server. Any PHP code in a requested file is executed by the PHP runtime, usually to create dynamic web page content. It can also be used for command-line scripting and client-side GUI applications.
As of April 2007, over 20 million Internet domains had web services hosted on servers with PHP installed and mod_php was recorded as the most popular Apache HTTP Server module. Significant websites are written in PHP including the user-facing portion of Facebook, Wikipedia (MediaWiki), Yahoo!, MyYearbook,Digg,Joomla, eZ Publish, WordPress, YouTube in its early stages, Drupal, Tagged and Moodle.
The National Vulnerability Database stores all vulnerabilities found in computer software. The overall proportion of PHP-related vulnerabilities on the database amounted to: 20% in 2004, 28% in 2005, 43% in 2006, 36% in 2007, 35% in 2008, and 30% in 2009. Most of these PHP-related vulnerabilities can be exploited remotely: they allow crackers to steal or destroy data from data sources linked to the webserver (such as an SQL database), send spam or contribute to DoS attacks using malware, which itself can be installed on the vulnerable servers. Security:
Syntax:  PHP only parses code within its delimiters. Anything outside its delimiters is sent directly to the output and is not processed by PHP (although non-PHP text is still subject to control structures described within PHP code). The most common delimiters are <?php to open and ?> to close PHP sections. <script language=&quot;php&quot;> and </script> delimiters are also available, as are the shortened forms <? or <?= (which is used to echo back a string or variable) and ?> as well as ASP-style short forms <% or <%= and %>. While short delimiters are used, they make script files less portable as their purpose can be disabled in the PHP configuration, and so they are discouraged.The purpose of all these delimiters is to separate PHP code from non-PHP code, including HTML
<html> <head> <title>PHP Test</title> </head> <body> <?php echo &quot;Hello World&quot;; /* echo(&quot;Hello World&quot;); works as well, although echo isn't a function (it's a language construct). In some cases, such as when multiple parameters are passed to echo, parameters cannot be enclosed in parentheses */ ?> </body> </html> Example:
INSTALLATION
Again the installation of the php editor will need the xampp server[ is a free and open source cross-platform web server package, consisting mainly of the Apache HTTP Server, MySQL database, and interpreters for scripts written in the PHP and Perl programming languages .] Step 1: We need to have the xampp for linux inorder the run applications so(as per step 1) ,download the xampp for linux with any favourable version on to the computer
Step 2: After the successful downloading,we need to extract the 'tar' file on to the system,select a path and just extract them using the following commands gunzip -d httpd-2_0_NN.tar.gz tar xvf httpd-2_0_NN.tar *NN -refers to the current xampp version
CONFIGURATION
PHP comes packaged with two INI files. One that is recommended to be used in production environments and one that is recommended to be used indevelopment environments. php.ini-production contains settings which hold security, performance and best practices at its core. But please be aware, these settings may break compatibility with older or less security conscience applications. We recommending using the production ini in production and testing environments. php.ini-development is very similar to its production variant, except it's much more verbose when it comes to errors. We recommending using the development version only in development environments as errors shown to application users can inadvertently leak otherwise secure information. CONFIGURATION FILE
Directives are specified using the following syntax: directive = value Directive names are *case sensitive* - foo=bar is different from FOO=bar. Directives are variables used to configure PHP or PHP extensions.There is no name validation.  If PHP can't find an expected directive because it is not set or is mistyped, a default value will be used. DIRECTORIES SPECIFICATION
EXPRESSIONS: Expressions in the INI file are limited to bitwise operators and parentheses: |  bitwise OR ^  bitwise XOR &  bitwise AND ~  bitwise NOT !  boolean NOT
EMPTY STRINGS: An empty string can be denoted by simply not writing anything after the equal sign, or by using the None keyword: ABC =  ; sets foo to an empty string ABC = None  ; sets foo to an empty string ABC = &quot;None&quot;  ; sets foo to the string 'None' *ABC -SECTION HEADER
php.ini OPTIONS Name for user-defined php.ini (.htaccess) files. Default is &quot;.user.ini&quot; user_ini.filename = &quot;.user.ini&quot; To disable this feature set this option to empty value user_ini.filename = TTL for user-defined php.ini files (time-to-live) in seconds. Default is 300 seconds (5 minutes) user_ini.cache_ttl = 300
LANGUAGE OPTIONS Enable the PHP scripting language engine under Apache. http://php.net/engine engine = On
SAFE MODE: Safe Mode http://php.net/safe-mode safe_mode = Off By default, Safe Mode does a UID compare check when opening files. If you want to relax this to a GID compare, then turn on safe_mode_gid. http://php.net/safe-mode-gid safe_mode_gid = Off When safe_mode is on, UID/GID checks are bypassed when including files from this directory and its subdirectories. (directory must also be in include_path or full path must be used when including) http://php.net/safe-mode-include-dir safe_mode_include_dir = When safe_mode is on, only executables located in the safe_mode_exec_dir will be allowed to be executed via the exec family of functions. http://php.net/safe-mode-exec-dir safe_mode_exec_dir
Functions and classes  This directive allows you to disable certain functions for security reasons. It receives a comma-delimited list of function names. This directive is *NOT* affected by whether Safe Mode is turned On or Off. http://php.net/disable-functions disable_functions = This directive allows you to disable certain classes for security reasons. It receives a comma-delimited list of class names. This directive is *NOT* affected by whether Safe Mode is turned On or Off. http://php.net/disable-classes disable_classes =
Color highlighting  Colors for Syntax Highlighting mode.  Anything that's acceptable in <span style=&quot;color: ???????&quot;> would work. http://php.net/syntax-highlighting highlight.string   = #DD0000 highlight.comment   = #FF9900 highlight.keyword  = #007700 highlight.bg    = #FFFFFF highlight.default    = #0000BB highlight.html   = #000000
RESOURCE LIMITS Maximum execution time of each script, in seconds http://php.net/max-execution-time Note: This directive is hardcoded to 0 for the CLI SAPI max_execution_time = 30  Maximum amount of time each script may spend parsing request data. It's a good idea to limit this time on productions servers in order to eliminate unexpectedly long running scripts.  Note: This directive is hardcoded to -1 for the CLI SAPI Default Value: -1 (Unlimited) Development Value: 60 (60 seconds) Production Value: 60 (60 seconds) http://php.net/max-input-time max_input_time = 60 Maximum input variable nesting level http://php.net/max-input-nesting-leve l max_input_nesting_level = 64 Maximum amount of memory a script may consume (128MB) http://php.net/memory-limit memory_limit = 128M
Error handling and logging ; This directive informs PHP of which errors, warnings and notices you would like ; it to take action for. The recommended way of setting values for this ; directive is through the use of the error level constants and bitwise ; operators. The error level constants are below here for convenience as well as ; some common settings and their meanings. ; By default, PHP is set to take action on all errors, notices and warnings EXCEPT ; those related to E_NOTICE and E_STRICT, which together cover best practices and ; recommended coding standards in PHP. For performance reasons, this is the ; recommend error reporting setting. Your production server shouldn't be wasting ; resources complaining about best practices and coding standards. That's what ; development servers and development settings are for.
Error Level Constants: E_ALL   - All errors and warnings  E_ERROR   - fatal run-time errors E_RECOVERABLE_ERROR   - almost fatal run-time errors E_WARNING   - run-time warnings (non-fatal errors) E_PARSE   - compile-time parse errors E_COMPILE_ERROR   - fatal compile-time errors E_USER_ERROR   - user-generated error message E_USER_WARNING  - user-generated warning message E_USER_NOTICE  - user-generated notice message E_DEPRECATED  - warn about code that will not work  in future versions of php
Paths and Directories: UNIX:  &quot;/path1:/path2&quot; include_path = &quot;.:/php/includes&quot; Windows:  &quot;ath1;ath2&quot; include_path = &quot;.;c:hpncludes&quot; PHP's  default setting for include_path is &quot;/path/to/php/pear&quot;
FILE UPLOADS: Whether to allow HTTP file uploads. http://php.net/file-uploads file_uploads = On Temporary directory for HTTP uploaded files (will use system default if notspecified). http://php.net/upload-tmp-dir upload_tmp_dir = Maximum allowed size for uploaded files. http://php.net/upload-max-filesize upload_max_filesize = 2M
DYNAMIC EXTENSIONS: If you wish to have an extension loaded automatically, use the following syntax: extension=modulename.extension For example, on Windows: extension=msql.dll ... or under UNIX: extension=msql.so ... or with a path: extension=/path/to/extension/msql.so

Mais conteúdo relacionado

Mais procurados (18)

Python Introduction
Python IntroductionPython Introduction
Python Introduction
 
Php1
Php1Php1
Php1
 
PHP programmimg
PHP programmimgPHP programmimg
PHP programmimg
 
Php
PhpPhp
Php
 
Php1
Php1Php1
Php1
 
Php intro
Php introPhp intro
Php intro
 
Beginners PHP Tutorial
Beginners PHP TutorialBeginners PHP Tutorial
Beginners PHP Tutorial
 
Winter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHPWinter%200405%20-%20Beginning%20PHP
Winter%200405%20-%20Beginning%20PHP
 
MySQL Presentation
MySQL PresentationMySQL Presentation
MySQL Presentation
 
Web programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh MalothWeb programming UNIT II by Bhavsingh Maloth
Web programming UNIT II by Bhavsingh Maloth
 
Unit 1
Unit 1Unit 1
Unit 1
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Php advance
Php advancePhp advance
Php advance
 
Phalcon 2 High Performance APIs - DevWeekPOA 2015
Phalcon 2 High Performance APIs - DevWeekPOA 2015Phalcon 2 High Performance APIs - DevWeekPOA 2015
Phalcon 2 High Performance APIs - DevWeekPOA 2015
 
PHP Project PPT
PHP Project PPTPHP Project PPT
PHP Project PPT
 
Class notes(week 10) on applet programming
Class notes(week 10) on applet programmingClass notes(week 10) on applet programming
Class notes(week 10) on applet programming
 
WoMakersCode 2016 - Shit Happens
WoMakersCode 2016 -  Shit HappensWoMakersCode 2016 -  Shit Happens
WoMakersCode 2016 - Shit Happens
 
Php
PhpPhp
Php
 

Semelhante a Php (20)

Php1
Php1Php1
Php1
 
Securing Your Web Server
Securing Your Web ServerSecuring Your Web Server
Securing Your Web Server
 
Php notes
Php notesPhp notes
Php notes
 
Php1
Php1Php1
Php1
 
Session10-PHP Misconfiguration
Session10-PHP MisconfigurationSession10-PHP Misconfiguration
Session10-PHP Misconfiguration
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
PHP ITCS 323
PHP ITCS 323PHP ITCS 323
PHP ITCS 323
 
Php Best Practices
Php Best PracticesPhp Best Practices
Php Best Practices
 
Php Best Practices
Php Best PracticesPhp Best Practices
Php Best Practices
 
PHP
PHPPHP
PHP
 
php basics
php basicsphp basics
php basics
 
My self learing -Php
My self learing -PhpMy self learing -Php
My self learing -Php
 
My self learn -Php
My self learn -PhpMy self learn -Php
My self learn -Php
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Php manish
Php manishPhp manish
Php manish
 

Mais de Rathan Raj

Mais de Rathan Raj (9)

Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
Photochemical smog
Photochemical smogPhotochemical smog
Photochemical smog
 
Web20
Web20Web20
Web20
 
Ajax
AjaxAjax
Ajax
 
Apache
ApacheApache
Apache
 
Css
CssCss
Css
 
Html
HtmlHtml
Html
 
Linux
LinuxLinux
Linux
 
Mysql
MysqlMysql
Mysql
 

Php

  • 1. PHP: Hypertext Preprocessor PHP: Hypertext Preprocessor is a widely used, general-purpose scripting language that was originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document.
  • 2. Usage: PHP is a general-purpose scripting language that is especially suited to server-side web development where PHP generally runs on a web server. Any PHP code in a requested file is executed by the PHP runtime, usually to create dynamic web page content. It can also be used for command-line scripting and client-side GUI applications.
  • 3. As of April 2007, over 20 million Internet domains had web services hosted on servers with PHP installed and mod_php was recorded as the most popular Apache HTTP Server module. Significant websites are written in PHP including the user-facing portion of Facebook, Wikipedia (MediaWiki), Yahoo!, MyYearbook,Digg,Joomla, eZ Publish, WordPress, YouTube in its early stages, Drupal, Tagged and Moodle.
  • 4. The National Vulnerability Database stores all vulnerabilities found in computer software. The overall proportion of PHP-related vulnerabilities on the database amounted to: 20% in 2004, 28% in 2005, 43% in 2006, 36% in 2007, 35% in 2008, and 30% in 2009. Most of these PHP-related vulnerabilities can be exploited remotely: they allow crackers to steal or destroy data from data sources linked to the webserver (such as an SQL database), send spam or contribute to DoS attacks using malware, which itself can be installed on the vulnerable servers. Security:
  • 5. Syntax: PHP only parses code within its delimiters. Anything outside its delimiters is sent directly to the output and is not processed by PHP (although non-PHP text is still subject to control structures described within PHP code). The most common delimiters are <?php to open and ?> to close PHP sections. <script language=&quot;php&quot;> and </script> delimiters are also available, as are the shortened forms <? or <?= (which is used to echo back a string or variable) and ?> as well as ASP-style short forms <% or <%= and %>. While short delimiters are used, they make script files less portable as their purpose can be disabled in the PHP configuration, and so they are discouraged.The purpose of all these delimiters is to separate PHP code from non-PHP code, including HTML
  • 6. <html> <head> <title>PHP Test</title> </head> <body> <?php echo &quot;Hello World&quot;; /* echo(&quot;Hello World&quot;); works as well, although echo isn't a function (it's a language construct). In some cases, such as when multiple parameters are passed to echo, parameters cannot be enclosed in parentheses */ ?> </body> </html> Example:
  • 8. Again the installation of the php editor will need the xampp server[ is a free and open source cross-platform web server package, consisting mainly of the Apache HTTP Server, MySQL database, and interpreters for scripts written in the PHP and Perl programming languages .] Step 1: We need to have the xampp for linux inorder the run applications so(as per step 1) ,download the xampp for linux with any favourable version on to the computer
  • 9. Step 2: After the successful downloading,we need to extract the 'tar' file on to the system,select a path and just extract them using the following commands gunzip -d httpd-2_0_NN.tar.gz tar xvf httpd-2_0_NN.tar *NN -refers to the current xampp version
  • 11. PHP comes packaged with two INI files. One that is recommended to be used in production environments and one that is recommended to be used indevelopment environments. php.ini-production contains settings which hold security, performance and best practices at its core. But please be aware, these settings may break compatibility with older or less security conscience applications. We recommending using the production ini in production and testing environments. php.ini-development is very similar to its production variant, except it's much more verbose when it comes to errors. We recommending using the development version only in development environments as errors shown to application users can inadvertently leak otherwise secure information. CONFIGURATION FILE
  • 12. Directives are specified using the following syntax: directive = value Directive names are *case sensitive* - foo=bar is different from FOO=bar. Directives are variables used to configure PHP or PHP extensions.There is no name validation. If PHP can't find an expected directive because it is not set or is mistyped, a default value will be used. DIRECTORIES SPECIFICATION
  • 13. EXPRESSIONS: Expressions in the INI file are limited to bitwise operators and parentheses: | bitwise OR ^ bitwise XOR & bitwise AND ~ bitwise NOT ! boolean NOT
  • 14. EMPTY STRINGS: An empty string can be denoted by simply not writing anything after the equal sign, or by using the None keyword: ABC = ; sets foo to an empty string ABC = None ; sets foo to an empty string ABC = &quot;None&quot; ; sets foo to the string 'None' *ABC -SECTION HEADER
  • 15. php.ini OPTIONS Name for user-defined php.ini (.htaccess) files. Default is &quot;.user.ini&quot; user_ini.filename = &quot;.user.ini&quot; To disable this feature set this option to empty value user_ini.filename = TTL for user-defined php.ini files (time-to-live) in seconds. Default is 300 seconds (5 minutes) user_ini.cache_ttl = 300
  • 16. LANGUAGE OPTIONS Enable the PHP scripting language engine under Apache. http://php.net/engine engine = On
  • 17. SAFE MODE: Safe Mode http://php.net/safe-mode safe_mode = Off By default, Safe Mode does a UID compare check when opening files. If you want to relax this to a GID compare, then turn on safe_mode_gid. http://php.net/safe-mode-gid safe_mode_gid = Off When safe_mode is on, UID/GID checks are bypassed when including files from this directory and its subdirectories. (directory must also be in include_path or full path must be used when including) http://php.net/safe-mode-include-dir safe_mode_include_dir = When safe_mode is on, only executables located in the safe_mode_exec_dir will be allowed to be executed via the exec family of functions. http://php.net/safe-mode-exec-dir safe_mode_exec_dir
  • 18. Functions and classes This directive allows you to disable certain functions for security reasons. It receives a comma-delimited list of function names. This directive is *NOT* affected by whether Safe Mode is turned On or Off. http://php.net/disable-functions disable_functions = This directive allows you to disable certain classes for security reasons. It receives a comma-delimited list of class names. This directive is *NOT* affected by whether Safe Mode is turned On or Off. http://php.net/disable-classes disable_classes =
  • 19. Color highlighting Colors for Syntax Highlighting mode. Anything that's acceptable in <span style=&quot;color: ???????&quot;> would work. http://php.net/syntax-highlighting highlight.string = #DD0000 highlight.comment = #FF9900 highlight.keyword = #007700 highlight.bg = #FFFFFF highlight.default = #0000BB highlight.html = #000000
  • 20. RESOURCE LIMITS Maximum execution time of each script, in seconds http://php.net/max-execution-time Note: This directive is hardcoded to 0 for the CLI SAPI max_execution_time = 30 Maximum amount of time each script may spend parsing request data. It's a good idea to limit this time on productions servers in order to eliminate unexpectedly long running scripts. Note: This directive is hardcoded to -1 for the CLI SAPI Default Value: -1 (Unlimited) Development Value: 60 (60 seconds) Production Value: 60 (60 seconds) http://php.net/max-input-time max_input_time = 60 Maximum input variable nesting level http://php.net/max-input-nesting-leve l max_input_nesting_level = 64 Maximum amount of memory a script may consume (128MB) http://php.net/memory-limit memory_limit = 128M
  • 21. Error handling and logging ; This directive informs PHP of which errors, warnings and notices you would like ; it to take action for. The recommended way of setting values for this ; directive is through the use of the error level constants and bitwise ; operators. The error level constants are below here for convenience as well as ; some common settings and their meanings. ; By default, PHP is set to take action on all errors, notices and warnings EXCEPT ; those related to E_NOTICE and E_STRICT, which together cover best practices and ; recommended coding standards in PHP. For performance reasons, this is the ; recommend error reporting setting. Your production server shouldn't be wasting ; resources complaining about best practices and coding standards. That's what ; development servers and development settings are for.
  • 22. Error Level Constants: E_ALL - All errors and warnings E_ERROR - fatal run-time errors E_RECOVERABLE_ERROR - almost fatal run-time errors E_WARNING - run-time warnings (non-fatal errors) E_PARSE - compile-time parse errors E_COMPILE_ERROR - fatal compile-time errors E_USER_ERROR - user-generated error message E_USER_WARNING - user-generated warning message E_USER_NOTICE - user-generated notice message E_DEPRECATED - warn about code that will not work in future versions of php
  • 23. Paths and Directories: UNIX: &quot;/path1:/path2&quot; include_path = &quot;.:/php/includes&quot; Windows: &quot;ath1;ath2&quot; include_path = &quot;.;c:hpncludes&quot; PHP's default setting for include_path is &quot;/path/to/php/pear&quot;
  • 24. FILE UPLOADS: Whether to allow HTTP file uploads. http://php.net/file-uploads file_uploads = On Temporary directory for HTTP uploaded files (will use system default if notspecified). http://php.net/upload-tmp-dir upload_tmp_dir = Maximum allowed size for uploaded files. http://php.net/upload-max-filesize upload_max_filesize = 2M
  • 25. DYNAMIC EXTENSIONS: If you wish to have an extension loaded automatically, use the following syntax: extension=modulename.extension For example, on Windows: extension=msql.dll ... or under UNIX: extension=msql.so ... or with a path: extension=/path/to/extension/msql.so