SlideShare a Scribd company logo
1 of 28
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. As a general-purpose programming language, PHP code is processed by an interpreter application in command-line mode performing desired operating system operations and producing program output on its standard output channel. It may also function as a graphical application. PHP is available as a processor for most modern web servers and as standalone interpreter on most operating systems and computing platforms. PHP was originally created by Rasmus Lerdorf in 1995 and has been in continuous development ever since. The main implementation of PHP is now produced by The PHP Group and serves as the de facto standard for PHP as there is no formal specification. PHP is free software released under the PHP License.
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. PHP can be deployed on most web servers, many operating systems and platforms, and can be used with many relational database management systems. It is available free of charge, and the PHP Group provides the complete source code for users to build, customize and extend for their own use. PHP primarily acts as a filter, taking input from a file or stream containing text and/or PHP instructions and outputs another stream of data; most commonly the output will be HTML. Since PHP 4, the PHP parser compiles input to produce bytecode for processing by the Zend Engine, giving improved performance over its interpreter predecessor. Originally designed to create dynamic web pages, PHP now focuses mainly on server-side scripting, and it is similar to other server-side scripting languages that provide dynamic content from a web server to a client, such as Microsoft's Active Server Pages, Sun Microsystems' JavaServer Pages, and mod perl. PHP has also attracted the development of many frameworks that provide building blocks and a design structure to promote rapid application development (RAD). Some of these include CakePHP, Symfony, CodeIgniter, and Zend Framework, offering features similar to other web application frameworks.
How To Install PHP On Linux This tutorial explains the installation of PHP 5, bundled with Apache and MySQL server on a Linux machine. The tutorial was written primarily for SuSE 9.2, 9.3, 10.0 & 10.1, but most of the steps ought to be valid for all Linux-like operating systems. We will set up PHP as a shared module, being loaded into Apache2 dynamically during the server startup. These instructions are known to work for PHP versions: 5.0.4 through 5.2.1. Prerequisites At this point Apache web server must be installed. If you want MySQL support in PHP, MySQL server also must have been installed prior to the next steps. Download Source Get the source from http://www.php.net/downloads.php  . At the time of writing this tutorial the best available version was 5.2.1 ( php-5.2.1.tar.gz ).
Unpack, Configure, Compile Go to the directory whith the downloaded file and enter: # tar -xzf php-5.2.1.tar.gz # cd php-5.2.1 # ./configure  --prefix=/usr/local/php  --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql The configuration options ought to be self-explaining; --prefix specifies the location where PHP is to be installed, --with-apxs2 with correct path pointing to bin/apxs in the Apache installation directory is mandatory for the installator to work. Since PHP 5, you need to explicitly bundle PHP with MySQL by --with-mysql directive (make sure you specified path to where MySQL is installed on your system). There are many other options which turn on additional features. For all available configuration options and their default values type ./configure --help.
TIP :  If you are performing an upgrade, you may want to copy config.nice from the old PHP installation directory (if available) to where you unpacked the new PHP tarball file. Run ./config.nice instead of ./configure. This way all the previous configure options will be applied to the new installation effortlessly. Once you entered ./configure with all the options you need, compile and install the software: # make # make install
Edit Httpd.conf All necessary changes to httpd.conf (Apache configuration file) should have already been made automatically during the installation, so usually you need not do anything. Nevertheless, check that following lines were added to the httpd.conf file: LoadModule php5_module modules/libphp5.so AddType application/x-httpd-php .php If not, add them manually. Create Php.ini File Importanly, you have to create a php.ini configuration file. Choose one of the pre-made files (preferably php.ini-recommended) residing inside the php-5.2.1/ directory (it's the folder to which the downloaded archive was extracted). Copy the file to the lib/ directory in the PHP installation directory. # cp php-5.2.1/php.ini-recommended /usr/local/php/lib/php.ini If you need to, edit the php.ini file: # vi /usr/local/php/lib/php.ini However, the default settings should work for everyone in most cases.
Restart Apache Server After everything is set up, restart Apache: # /usr/local/bin/apachectl restart Further Reading PHP Manual Do you have an idea how to make these instructions better? Did you run into any problems or have any tips? You are welcome to share your experience in the comment s.
PHP CONFIGURATION
PHP's initialization file, generally called php.ini, is responsible for ; configuring many of the aspects of PHP's behavior. PHP attempts to find and load this configuration from a number of locations. The following is a summary of its search order: 1. SAPI module specific location. 2. The PHPRC environment variable. (As of PHP 5.2.0) 3. A number of predefined registry keys on Windows (As of PHP 5.2.0) 4. Current working directory (except CLI) 5. The web server's directory (for SAPI modules), or directory of PHP (otherwise in Windows) 6. The directory from the --with-config-file-path compile time option, or the Windows directory (C:indows or C:innt) See the PHP docs for more specific information. http://php.net/configuration.file The syntax of the file is extremely simple.  Whitespace and Lines beginning with a semicolon are silently ignored (as you probably guessed). Section headers (e.g. [Foo]) are also silently ignored, even though they might mean something in the future.
Directives  following the section heading [PATH=/www/mysite] only apply to PHP files in the /www/mysite directory.  Directives following the section heading [HOST=www.example.com] only apply to PHP files served from www.example.com.  Directives set in these special sections cannot be overridden by user-defined INI files or at runtime. Currently, [PATH=] and [HOST=] sections only work under CGI/FastCGI. http://php.net/ini.sections 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. The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one of the INI constants (On, Off, True, False, Yes, No and None) or an expression (e.g. E_ALL & ~E_NOTICE), a quoted string ("bar"), or a reference to a previously set variable or directive (e.g. ${foo})
About this file 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 in ; development 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.
Quick Reference The following are all the settings which are different in either the production ; or development versions of the INIs with respect to PHP's default behavior. ; Please see the actual settings later in the document for more details as to why ; we recommend these changes in PHP's behavior. ; allow_call_time_pass_reference ;  Default Value: On ;  Development Value: Off ;  Production Value: Off ; display_errors ;  Default Value: On ;  Development Value: On ;  Production Value: Off ; display_startup_errors ;  Default Value: Off ;  Development Value: On ;  Production Value: Off ; error_reporting ;  Default Value: E_ALL & ~E_NOTICE ;  Development Value: E_ALL | E_STRICT ;  Production Value: E_ALL & ~E_DEPRECATED
l og_errors ;  Default Value: Off ;  Development Value: On ;  Production Value: On ; magic_quotes_gpc ;  Default Value: On ;  Development Value: Off ;  Production Value: Off ; max_input_time ;  Default Value: -1 (Unlimited) ;  Development Value: 60 (60 seconds) ;  Production Value: 60 (60 seconds) ; output_buffering ;  Default Value: Off ;  Development Value: 4096 ;  Production Value: 4096 ; register_argc_argv ;  Default Value: On ;  Development Value: Off ;  Production Value: Off ; register_long_arrays ;  Default Value: On ;  Development Value: Off ;  Production Value: Off
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 This directive determines whether or not PHP will recognize code between ; <? and ?> tags as PHP source which should be processed as such. It's been ; recommended for several years that you not use the short tag &quot;short cut&quot; and ; instead to use the full <?php and ?> tag combination. With the wide spread use ; of XML and use of these tags by other languages, the server can become easily ; confused and end up parsing the wrong code in the wrong context. But because ; this short cut has been a feature for such a long time, it's currently still ; supported for backwards compatibility, but we recommend you don't use them.
PHP COMMANDS
PHP VARIABLES Variable Types Variables play an important role in PHP, as they are places for holding values. In PHP, there is no need to declare variables. Variable can hold eight different data types: bloolean, integer, float, string, array, object, resource, or NULL. PHP is a weakly typed language. This means that variable type varies depending on what is stored in the variable at the time. For example, if we have a variable $a, when $a = 0, $a is an integer type variable. If later we set $a = &quot;New&quot;, then $a becomes a string type variable. Variable Name A variable name always starts with a $, followed by a letter or an underscore. The rest of the variable name can be a letter, a number or an underscore. For example, $dog is a valid variable name, while @dog is not (@dog does not start with a $). Variables in PHP are case-sensitive. For example, $Employee and $employee are two different variables.
PHP OPERATORS Assignment Operators The basic assignment operator in PHP is &quot;=&quot;. This means that the operand to the left of &quot;=&quot; gets set to the value to the right of &quot;=&quot;. Arithmetic Operators Operator Example Result + 4 + 2    6 - 4 - 2   2 * 4 * 2   8 / 4 / 2   2 % 4 %  20 ++ x = 4; x++;   x = 5 -- x = 4; x--;   x = 3 Combined Operators You can combine an arithmetic operator with the assignment operator to form a combined operator. Combined operators are shown below: Operator Example Meaning += y += x   y = y + x -= y -= x   y = y - x *= y *= x   y = y * x /= y /= x   y = y / x %= y %= x   y = y % x
Comparison Operators Operator Meaning == is equal to != is not equal to > is greater than >= is greater than or equal to < is less than <= is less than or equal to Logical Operators Operator Meaning || or && and and and or or xor xor ! not
PHP IF ELSE IF..ELSE is used in PHP to provide conditional judgements. The basic syntax is as follows: IF (conditional statement) { [code if condition is true] } ELSE { [code if condition is false] } Let's see an example. Assuming we have the following piece of code: $sample = 10; IF ($sample > 5) { print &quot;Number is greater than 5&quot;; } ELSE { print &quot;Number is less than 5&quot;; } The output of the above code is: Number is greater than 5
PHP FUNCTIONS Similar to other programming languages, PHP provides a way for programmers to define functions, which can then be called elsewhere in the program. The syntax for a function is: function &quot;function_name&quot; (arg1, arg2...) { [code to execute] return [final_result]; } where [final_result] is typically the variable holding the final value to be returned from the function. Let's take a look at an example: function double_this_number($input_number) { return $input_number*2; } Elsewhere in the PHP code, we have $x = 10; $y = double_this_number($x); print $y; The output will be 20
PHP ARRAYS  An array is a way of holding multiple closely-related values, such as the test scores of all students in a class. An array is made up of a key and a value, and the key points to the value. There are two types of arrays: Indexed array and Associative array. Their difference is in the way the key is specified. Let's look at both of them: Indexed Array In an indexed array, the keys are numeric and starts with 0, and the values can be any data type. The following shows two ways of assigning values to an indexed array: $friends = array(&quot;Sophie&quot;,&quot;Stella&quot;,&quot;Alice&quot;); This is equivalent to the following: $friends[0] = &quot;Sophie&quot;; $friends[1] = &quot;Stella&quot;; $friends[2] = &quot;Alice&quot;;
PHP FORMS One of the main features in PHP is the ability to take user input and generate subsequent pages based on the input. In this page, we will introduce the mechanism by which data is passed in PHP. Let's consider the following two files: query.php <form action=result.php type=post> <input type=text name=employee> <input type=submit value=Submit> </form> result.php <?php $employee_name = $_POST[&quot;employee&quot;]; print $employee_name; ?>
PHP COOKIES Create cookies Cookies are set using the setcookie() function. The syntax is as follows: Setcookie (name, value, expire, path, domain, secure) name = name of the cookie. value = value of the cookie. expire = time when this cookie will expire. Unix time is used here. path = the path on the server on which the cookie is available. domain = the domain that the cookie is available. secure = TRUE means the cookie should be trasmitted over a secure connection (https), FALSE otherwise. FALSE is the default. All arguments except name are optional. Unix time is the number of seconds that have elapsed since January 1, 1970. You must make sure that the setcookie() function is called before any HTML output is printed. Let's take a look at a couple of examples: <?php setcookie('cookie1','lisa'); ?>
PHP MYSQL The PHP code needed is as follows (assuming the MySQL Server sits in localhost and has a userid = 'cat' and a password of 'dog', the database name is 'myinfo') : $link = @mysql_pconnect(&quot;localhost&quot;,&quot;cat&quot;,&quot;dog&quot;) or exit(); mysql_select_db(&quot;myinfo&quot;) or exit(); print &quot;<p>Employee Information&quot;; print &quot;<p><table border=1><tr><td>Employee Name</td><td>Salary Amount</td></tr>&quot;; $result = mysql_query(&quot;select name, salary from Employee&quot;); while ($row=mysql_fetch_row($result)) { print &quot;<tr><td>&quot; . $row[0] . &quot;</td><td>&quot; . $row[1] . &quot;</td></tr>&quot;; } print &quot;</table>&quot;; Output is Employee Information Employee Name Salary Amount Lisa 40000 Alice 45000 Janine 60000
PHP SYNTAX DO ... WHILE DO { [code to execute] } WHILE (conditional statement) ELSEIF IF (conditional statement 1) { [code if condition statement 1 is true] } ELSEIF (conditional statement 2) { [code if condition statement 2 is true] } ELSE { [code if neither statement is true] } FOR Loop FOR (expression 1, expression 2, expression 3) { [code to execute] }
FOREACH Loop FOREACH ($array_variable as $value) { [code to execute] } or FOREACH ($array_variable as $key => $value) { [code to execute] } IF ELSE IF (conditional statement) { [code if condition is true] } ELSE { [code if condition is false] }
Include INCLUDE (&quot;external_file_name&quot;); SWITCH ($variable) { CASE 'value 1': [code to execute when $variable = 'value 1'] break; CASE 'value 2': [code to execute when $variable = 'value 2'] break; CASE 'value 3': ... DEFAULT: [code to execute when none of the CASE values matches $variable'] } WHILE Loop WHILE (expression) { [code to execute] }
THANK YOU

More Related Content

What's hot (20)

Php technical presentation
Php technical presentationPhp technical presentation
Php technical presentation
 
Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1Web Development Course: PHP lecture 1
Web Development Course: PHP lecture 1
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Php introduction
Php introductionPhp introduction
Php introduction
 
Basics PHP
Basics PHPBasics PHP
Basics PHP
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
Web Devlopment ppt.pptx
Web Devlopment ppt.pptxWeb Devlopment ppt.pptx
Web Devlopment ppt.pptx
 
virtual hosting and configuration
virtual hosting and configurationvirtual hosting and configuration
virtual hosting and configuration
 
HTTP request and response
HTTP request and responseHTTP request and response
HTTP request and response
 
Selenium
SeleniumSelenium
Selenium
 
Php with MYSQL Database
Php with MYSQL DatabasePhp with MYSQL Database
Php with MYSQL Database
 
Php basics
Php basicsPhp basics
Php basics
 
Php
PhpPhp
Php
 
Php Tutorials for Beginners
Php Tutorials for BeginnersPhp Tutorials for Beginners
Php Tutorials for Beginners
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
Liit tyit sem 5 enterprise java unit 4 notes mosst important questions with s...
Liit tyit sem 5 enterprise java unit 4 notes mosst important questions with s...Liit tyit sem 5 enterprise java unit 4 notes mosst important questions with s...
Liit tyit sem 5 enterprise java unit 4 notes mosst important questions with s...
 
Lesson 2 php data types
Lesson 2   php data typesLesson 2   php data types
Lesson 2 php data types
 
Php
PhpPhp
Php
 
Introduction to xampp
Introduction to xamppIntroduction to xampp
Introduction to xampp
 
Apache web server
Apache web serverApache web server
Apache web server
 

Viewers also liked

PHP Summer Training Presentation
PHP Summer Training PresentationPHP Summer Training Presentation
PHP Summer Training PresentationNitesh Sharma
 
Beginners PHP Tutorial
Beginners PHP TutorialBeginners PHP Tutorial
Beginners PHP Tutorialalexjones89
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHPBradley Holt
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisIan Macali
 
Array in php
Array in phpArray in php
Array in phpilakkiya
 
Dynamic HTML Event Model
Dynamic HTML Event ModelDynamic HTML Event Model
Dynamic HTML Event ModelReem Alattas
 
Even internet computers want to be free: Using Linux and open source software...
Even internet computers want to be free: Using Linux and open source software...Even internet computers want to be free: Using Linux and open source software...
Even internet computers want to be free: Using Linux and open source software...North Bend Public Library
 
14. session 14 dhtml filter
14. session 14   dhtml filter14. session 14   dhtml filter
14. session 14 dhtml filterPhúc Đỗ
 
Php File Operations
Php File OperationsPhp File Operations
Php File Operationsmussawir20
 
What's new in PHP 7.1
What's new in PHP 7.1What's new in PHP 7.1
What's new in PHP 7.1Simon Jones
 

Viewers also liked (20)

PHP Project PPT
PHP Project PPTPHP Project PPT
PHP Project PPT
 
Php Ppt
Php PptPhp Ppt
Php Ppt
 
PHP Summer Training Presentation
PHP Summer Training PresentationPHP Summer Training Presentation
PHP Summer Training Presentation
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
Beginners PHP Tutorial
Beginners PHP TutorialBeginners PHP Tutorial
Beginners PHP Tutorial
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
 
Array in php
Array in phpArray in php
Array in php
 
Dynamic HTML Event Model
Dynamic HTML Event ModelDynamic HTML Event Model
Dynamic HTML Event Model
 
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
 
Php array
Php arrayPhp array
Php array
 
Even internet computers want to be free: Using Linux and open source software...
Even internet computers want to be free: Using Linux and open source software...Even internet computers want to be free: Using Linux and open source software...
Even internet computers want to be free: Using Linux and open source software...
 
MySQL and its basic commands
MySQL and its basic commandsMySQL and its basic commands
MySQL and its basic commands
 
PHP array 1
PHP array 1PHP array 1
PHP array 1
 
14. session 14 dhtml filter
14. session 14   dhtml filter14. session 14   dhtml filter
14. session 14 dhtml filter
 
Php File Operations
Php File OperationsPhp File Operations
Php File Operations
 
What's new in PHP 7.1
What's new in PHP 7.1What's new in PHP 7.1
What's new in PHP 7.1
 
Php string function
Php string function Php string function
Php string function
 

Similar to Php ppt (20)

Php.ppt
Php.pptPhp.ppt
Php.ppt
 
Php
PhpPhp
Php
 
Php
PhpPhp
Php
 
Php notes
Php notesPhp notes
Php notes
 
PHP
PHPPHP
PHP
 
Php1
Php1Php1
Php1
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Php1
Php1Php1
Php1
 
Php1
Php1Php1
Php1
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
How PHP works
How PHP works How PHP works
How PHP works
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
php basics
php basicsphp basics
php basics
 
PHP ITCS 323
PHP ITCS 323PHP ITCS 323
PHP ITCS 323
 
Php
PhpPhp
Php
 
Php1
Php1Php1
Php1
 
Php1(2)
Php1(2)Php1(2)
Php1(2)
 
Php Ppt
Php PptPhp Ppt
Php Ppt
 

More from Sanmuga Nathan (8)

Html Ppt
Html PptHtml Ppt
Html Ppt
 
Web2.0 ppt
Web2.0 pptWeb2.0 ppt
Web2.0 ppt
 
Ajax ppt
Ajax pptAjax ppt
Ajax ppt
 
Apache ppt
Apache pptApache ppt
Apache ppt
 
CSS ppt
CSS pptCSS ppt
CSS ppt
 
Html ppt
Html pptHtml ppt
Html ppt
 
Linux ppt
Linux pptLinux ppt
Linux ppt
 
Mysql ppt
Mysql pptMysql ppt
Mysql ppt
 

Recently uploaded

POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 

Recently uploaded (20)

Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 

Php ppt

  • 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. As a general-purpose programming language, PHP code is processed by an interpreter application in command-line mode performing desired operating system operations and producing program output on its standard output channel. It may also function as a graphical application. PHP is available as a processor for most modern web servers and as standalone interpreter on most operating systems and computing platforms. PHP was originally created by Rasmus Lerdorf in 1995 and has been in continuous development ever since. The main implementation of PHP is now produced by The PHP Group and serves as the de facto standard for PHP as there is no formal specification. PHP is free software released under the PHP License.
  • 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. PHP can be deployed on most web servers, many operating systems and platforms, and can be used with many relational database management systems. It is available free of charge, and the PHP Group provides the complete source code for users to build, customize and extend for their own use. PHP primarily acts as a filter, taking input from a file or stream containing text and/or PHP instructions and outputs another stream of data; most commonly the output will be HTML. Since PHP 4, the PHP parser compiles input to produce bytecode for processing by the Zend Engine, giving improved performance over its interpreter predecessor. Originally designed to create dynamic web pages, PHP now focuses mainly on server-side scripting, and it is similar to other server-side scripting languages that provide dynamic content from a web server to a client, such as Microsoft's Active Server Pages, Sun Microsystems' JavaServer Pages, and mod perl. PHP has also attracted the development of many frameworks that provide building blocks and a design structure to promote rapid application development (RAD). Some of these include CakePHP, Symfony, CodeIgniter, and Zend Framework, offering features similar to other web application frameworks.
  • 3. How To Install PHP On Linux This tutorial explains the installation of PHP 5, bundled with Apache and MySQL server on a Linux machine. The tutorial was written primarily for SuSE 9.2, 9.3, 10.0 & 10.1, but most of the steps ought to be valid for all Linux-like operating systems. We will set up PHP as a shared module, being loaded into Apache2 dynamically during the server startup. These instructions are known to work for PHP versions: 5.0.4 through 5.2.1. Prerequisites At this point Apache web server must be installed. If you want MySQL support in PHP, MySQL server also must have been installed prior to the next steps. Download Source Get the source from http://www.php.net/downloads.php . At the time of writing this tutorial the best available version was 5.2.1 ( php-5.2.1.tar.gz ).
  • 4. Unpack, Configure, Compile Go to the directory whith the downloaded file and enter: # tar -xzf php-5.2.1.tar.gz # cd php-5.2.1 # ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql The configuration options ought to be self-explaining; --prefix specifies the location where PHP is to be installed, --with-apxs2 with correct path pointing to bin/apxs in the Apache installation directory is mandatory for the installator to work. Since PHP 5, you need to explicitly bundle PHP with MySQL by --with-mysql directive (make sure you specified path to where MySQL is installed on your system). There are many other options which turn on additional features. For all available configuration options and their default values type ./configure --help.
  • 5. TIP : If you are performing an upgrade, you may want to copy config.nice from the old PHP installation directory (if available) to where you unpacked the new PHP tarball file. Run ./config.nice instead of ./configure. This way all the previous configure options will be applied to the new installation effortlessly. Once you entered ./configure with all the options you need, compile and install the software: # make # make install
  • 6. Edit Httpd.conf All necessary changes to httpd.conf (Apache configuration file) should have already been made automatically during the installation, so usually you need not do anything. Nevertheless, check that following lines were added to the httpd.conf file: LoadModule php5_module modules/libphp5.so AddType application/x-httpd-php .php If not, add them manually. Create Php.ini File Importanly, you have to create a php.ini configuration file. Choose one of the pre-made files (preferably php.ini-recommended) residing inside the php-5.2.1/ directory (it's the folder to which the downloaded archive was extracted). Copy the file to the lib/ directory in the PHP installation directory. # cp php-5.2.1/php.ini-recommended /usr/local/php/lib/php.ini If you need to, edit the php.ini file: # vi /usr/local/php/lib/php.ini However, the default settings should work for everyone in most cases.
  • 7. Restart Apache Server After everything is set up, restart Apache: # /usr/local/bin/apachectl restart Further Reading PHP Manual Do you have an idea how to make these instructions better? Did you run into any problems or have any tips? You are welcome to share your experience in the comment s.
  • 9. PHP's initialization file, generally called php.ini, is responsible for ; configuring many of the aspects of PHP's behavior. PHP attempts to find and load this configuration from a number of locations. The following is a summary of its search order: 1. SAPI module specific location. 2. The PHPRC environment variable. (As of PHP 5.2.0) 3. A number of predefined registry keys on Windows (As of PHP 5.2.0) 4. Current working directory (except CLI) 5. The web server's directory (for SAPI modules), or directory of PHP (otherwise in Windows) 6. The directory from the --with-config-file-path compile time option, or the Windows directory (C:indows or C:innt) See the PHP docs for more specific information. http://php.net/configuration.file The syntax of the file is extremely simple. Whitespace and Lines beginning with a semicolon are silently ignored (as you probably guessed). Section headers (e.g. [Foo]) are also silently ignored, even though they might mean something in the future.
  • 10. Directives following the section heading [PATH=/www/mysite] only apply to PHP files in the /www/mysite directory. Directives following the section heading [HOST=www.example.com] only apply to PHP files served from www.example.com. Directives set in these special sections cannot be overridden by user-defined INI files or at runtime. Currently, [PATH=] and [HOST=] sections only work under CGI/FastCGI. http://php.net/ini.sections 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. The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one of the INI constants (On, Off, True, False, Yes, No and None) or an expression (e.g. E_ALL & ~E_NOTICE), a quoted string (&quot;bar&quot;), or a reference to a previously set variable or directive (e.g. ${foo})
  • 11. About this file 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 in ; development 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.
  • 12. Quick Reference The following are all the settings which are different in either the production ; or development versions of the INIs with respect to PHP's default behavior. ; Please see the actual settings later in the document for more details as to why ; we recommend these changes in PHP's behavior. ; allow_call_time_pass_reference ; Default Value: On ; Development Value: Off ; Production Value: Off ; display_errors ; Default Value: On ; Development Value: On ; Production Value: Off ; display_startup_errors ; Default Value: Off ; Development Value: On ; Production Value: Off ; error_reporting ; Default Value: E_ALL & ~E_NOTICE ; Development Value: E_ALL | E_STRICT ; Production Value: E_ALL & ~E_DEPRECATED
  • 13. l og_errors ; Default Value: Off ; Development Value: On ; Production Value: On ; magic_quotes_gpc ; Default Value: On ; Development Value: Off ; Production Value: Off ; max_input_time ; Default Value: -1 (Unlimited) ; Development Value: 60 (60 seconds) ; Production Value: 60 (60 seconds) ; output_buffering ; Default Value: Off ; Development Value: 4096 ; Production Value: 4096 ; register_argc_argv ; Default Value: On ; Development Value: Off ; Production Value: Off ; register_long_arrays ; Default Value: On ; Development Value: Off ; Production Value: Off
  • 14. 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 This directive determines whether or not PHP will recognize code between ; <? and ?> tags as PHP source which should be processed as such. It's been ; recommended for several years that you not use the short tag &quot;short cut&quot; and ; instead to use the full <?php and ?> tag combination. With the wide spread use ; of XML and use of these tags by other languages, the server can become easily ; confused and end up parsing the wrong code in the wrong context. But because ; this short cut has been a feature for such a long time, it's currently still ; supported for backwards compatibility, but we recommend you don't use them.
  • 16. PHP VARIABLES Variable Types Variables play an important role in PHP, as they are places for holding values. In PHP, there is no need to declare variables. Variable can hold eight different data types: bloolean, integer, float, string, array, object, resource, or NULL. PHP is a weakly typed language. This means that variable type varies depending on what is stored in the variable at the time. For example, if we have a variable $a, when $a = 0, $a is an integer type variable. If later we set $a = &quot;New&quot;, then $a becomes a string type variable. Variable Name A variable name always starts with a $, followed by a letter or an underscore. The rest of the variable name can be a letter, a number or an underscore. For example, $dog is a valid variable name, while @dog is not (@dog does not start with a $). Variables in PHP are case-sensitive. For example, $Employee and $employee are two different variables.
  • 17. PHP OPERATORS Assignment Operators The basic assignment operator in PHP is &quot;=&quot;. This means that the operand to the left of &quot;=&quot; gets set to the value to the right of &quot;=&quot;. Arithmetic Operators Operator Example Result + 4 + 2 6 - 4 - 2 2 * 4 * 2 8 / 4 / 2 2 % 4 % 20 ++ x = 4; x++; x = 5 -- x = 4; x--; x = 3 Combined Operators You can combine an arithmetic operator with the assignment operator to form a combined operator. Combined operators are shown below: Operator Example Meaning += y += x y = y + x -= y -= x y = y - x *= y *= x y = y * x /= y /= x y = y / x %= y %= x y = y % x
  • 18. Comparison Operators Operator Meaning == is equal to != is not equal to > is greater than >= is greater than or equal to < is less than <= is less than or equal to Logical Operators Operator Meaning || or && and and and or or xor xor ! not
  • 19. PHP IF ELSE IF..ELSE is used in PHP to provide conditional judgements. The basic syntax is as follows: IF (conditional statement) { [code if condition is true] } ELSE { [code if condition is false] } Let's see an example. Assuming we have the following piece of code: $sample = 10; IF ($sample > 5) { print &quot;Number is greater than 5&quot;; } ELSE { print &quot;Number is less than 5&quot;; } The output of the above code is: Number is greater than 5
  • 20. PHP FUNCTIONS Similar to other programming languages, PHP provides a way for programmers to define functions, which can then be called elsewhere in the program. The syntax for a function is: function &quot;function_name&quot; (arg1, arg2...) { [code to execute] return [final_result]; } where [final_result] is typically the variable holding the final value to be returned from the function. Let's take a look at an example: function double_this_number($input_number) { return $input_number*2; } Elsewhere in the PHP code, we have $x = 10; $y = double_this_number($x); print $y; The output will be 20
  • 21. PHP ARRAYS An array is a way of holding multiple closely-related values, such as the test scores of all students in a class. An array is made up of a key and a value, and the key points to the value. There are two types of arrays: Indexed array and Associative array. Their difference is in the way the key is specified. Let's look at both of them: Indexed Array In an indexed array, the keys are numeric and starts with 0, and the values can be any data type. The following shows two ways of assigning values to an indexed array: $friends = array(&quot;Sophie&quot;,&quot;Stella&quot;,&quot;Alice&quot;); This is equivalent to the following: $friends[0] = &quot;Sophie&quot;; $friends[1] = &quot;Stella&quot;; $friends[2] = &quot;Alice&quot;;
  • 22. PHP FORMS One of the main features in PHP is the ability to take user input and generate subsequent pages based on the input. In this page, we will introduce the mechanism by which data is passed in PHP. Let's consider the following two files: query.php <form action=result.php type=post> <input type=text name=employee> <input type=submit value=Submit> </form> result.php <?php $employee_name = $_POST[&quot;employee&quot;]; print $employee_name; ?>
  • 23. PHP COOKIES Create cookies Cookies are set using the setcookie() function. The syntax is as follows: Setcookie (name, value, expire, path, domain, secure) name = name of the cookie. value = value of the cookie. expire = time when this cookie will expire. Unix time is used here. path = the path on the server on which the cookie is available. domain = the domain that the cookie is available. secure = TRUE means the cookie should be trasmitted over a secure connection (https), FALSE otherwise. FALSE is the default. All arguments except name are optional. Unix time is the number of seconds that have elapsed since January 1, 1970. You must make sure that the setcookie() function is called before any HTML output is printed. Let's take a look at a couple of examples: <?php setcookie('cookie1','lisa'); ?>
  • 24. PHP MYSQL The PHP code needed is as follows (assuming the MySQL Server sits in localhost and has a userid = 'cat' and a password of 'dog', the database name is 'myinfo') : $link = @mysql_pconnect(&quot;localhost&quot;,&quot;cat&quot;,&quot;dog&quot;) or exit(); mysql_select_db(&quot;myinfo&quot;) or exit(); print &quot;<p>Employee Information&quot;; print &quot;<p><table border=1><tr><td>Employee Name</td><td>Salary Amount</td></tr>&quot;; $result = mysql_query(&quot;select name, salary from Employee&quot;); while ($row=mysql_fetch_row($result)) { print &quot;<tr><td>&quot; . $row[0] . &quot;</td><td>&quot; . $row[1] . &quot;</td></tr>&quot;; } print &quot;</table>&quot;; Output is Employee Information Employee Name Salary Amount Lisa 40000 Alice 45000 Janine 60000
  • 25. PHP SYNTAX DO ... WHILE DO { [code to execute] } WHILE (conditional statement) ELSEIF IF (conditional statement 1) { [code if condition statement 1 is true] } ELSEIF (conditional statement 2) { [code if condition statement 2 is true] } ELSE { [code if neither statement is true] } FOR Loop FOR (expression 1, expression 2, expression 3) { [code to execute] }
  • 26. FOREACH Loop FOREACH ($array_variable as $value) { [code to execute] } or FOREACH ($array_variable as $key => $value) { [code to execute] } IF ELSE IF (conditional statement) { [code if condition is true] } ELSE { [code if condition is false] }
  • 27. Include INCLUDE (&quot;external_file_name&quot;); SWITCH ($variable) { CASE 'value 1': [code to execute when $variable = 'value 1'] break; CASE 'value 2': [code to execute when $variable = 'value 2'] break; CASE 'value 3': ... DEFAULT: [code to execute when none of the CASE values matches $variable'] } WHILE Loop WHILE (expression) { [code to execute] }