SlideShare ist ein Scribd-Unternehmen logo
1 von 25
PHP INTRODUCTION
BY
SANA MATEEN
What is PHP?
1. PHP is a server scripting language, and a powerful tool for making dynamic and
interactive Web pages.
2. PHP is a widely-used, free, and efficient alternative to competitors such as
Microsoft's ASP.
3. PHP is an acronym for "PHP: Hypertext Preprocessor"
4. PHP is a widely-used, open source scripting language
5. PHP scripts are executed on the server
6. PHP is free to download and use
What is a PHP File?
1. PHP files can contain text, HTML, CSS, JavaScript, and PHP code
2. PHP code are executed on the server, and the result is returned to the browser as
plain HTML
3. PHP files have extension ".php"
What Can PHP Do?
1. PHP can generate dynamic page content
2. PHP can create, open, read, write, delete, and close files on the server
3. PHP can collect form data
4. PHP can send and receive cookies
5. PHP can add, delete, modify data in your database
6. PHP can be used to control user-access
7. PHP can encrypt data
8. With PHP you are not limited to output HTML. You can output images,
PDF files, and even Flash movies. You can also output any text, such as
XHTML and XML.
• Why PHP?
1. PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
2. PHP is compatible with almost all servers used today (Apache, IIS, etc.)
3. PHP supports a wide range of databases
4. PHP is free. Download it from the official PHP resource: www.php.net
5. PHP is easy to learn and runs efficiently on the server side
PHP INSTALLATION
• What Do I Need?
1. To start using PHP, you can:
2. Find a web host with PHP and MySQL support
3. Install a web server on your own PC, and then install PHP and MySQL
• Use a Web Host With PHP Support
1. If your server has activated support for PHP you do not need to do
anything.
2. Just create some .php files, place them in your web directory, and the
server will automatically parse them for you.
3. You do not need to compile anything or install any extra tools.
4. Because PHP is free, most web hosts offer PHP support.
• Set Up PHP on Your Own PC
1. However, if your server does not support PHP, you must:
2. install a web server
3. install PHP
4. install a database, such as MySQL
5. The official PHP website (PHP.net) has installation instructions for
PHP: http://php.net/manual/en/install.php
INSTALLATION PREREQUISITES
• Downloading Apache
• These days, Apache is packaged with all mainstream Linux distributions. So if
you’re using one of these platforms, chances are quite good you already have it
installed or can easily install it through your distribution’s packaging service (e.g.,
by running the apt-get command on Ubuntu).
• If you’re running Windows and would like to use Apache, then download the latest
stable Windows binary located within the binaries/win32 directory. Two binary
versions are available: one containing additional SSL-related capabilities and one
lacking these capabilities. It is suggested choosing the non-SSL capable version for
development purposes.
• Downloading PHP
• Windows zip package: If you plan to use PHP in conjunction with Apache on
Windows, you should download this distribution because it’s the focus of the later
installation instructions.
• Windows installer: This version offers a convenient Windows installer interface
for installing and configuring PHP, plus support for automatically configuring the
IIS, PWS, and Xitami servers.
PHP SYNTAX
• A PHP script is executed on the server, and the plain HTML result is sent
back to the browser.
• Basic PHP Syntax
• A PHP script can be placed anywhere in the document.
• A PHP script starts with <?php and ends with ?>:
• <?php
// PHP code goes here
?>
• The default file extension for PHP files is ".php".
• A PHP file normally contains HTML tags, and some PHP scripting code.
PHP FEATURES
• Practicality
• After all, Lerdorf’s original intention was not to design an entirely new
language, but to resolve a problem that had no readily available solution.
• For instance, a useful PHP script can consist of as little as one line; unlike C,
there is no need for the mandatory inclusion of libraries.
• For example, the following represents a complete PHP script, the purpose of
which is to output the current date, in this case one formatted like September
23, 2007: <?php echo date("F j, Y"); ?>
• PHP is a loosely typed language, meaning there is no need to explicitly create,
typecast, or destroy a variable, although you are not prevented from doing so.
• Power
• Create and manipulate Adobe Flash and Portable Document Format (PDF) files.
• Parse even the most complex of strings using the POSIX and Perl-based regular
expression libraries.
• Authenticate users against login credentials stored in flat files, databases, and
even Microsoft’s Active Directory.
• Communicate with a wide variety of protocols, including LDAP, IMAP, POP3,
NNTP, and DNS, among others.
Possibility
1. For example, consider PHP’s array of
database support options.
2. Native support is offered for more
than 25 database products, including
IBM DB2, mSQL, Microsoft SQL
Server, MySQL, Oracle, PostgreSQL,
Solid, Sybase, Unix dbm, and Velocis
3. PHP’s flexible string-parsing
capabilities offer users of differing skill
sets the opportunity to not only
immediately begin performing
complex string operations but also to
quickly port programs of similar
functionality (such as Perl and Python)
over to PHP
Price
1. PHP is available free of charge! Since its
inception, PHP has been without usage,
modification, and redistribution
restrictions.
2. Free of licensing restrictions imposed by
most commercial products:
3. Although some discrepancies do exist
among license variants, users are largely
free to modify, redistribute, and integrate
the software into other products.
4. Open development and auditing process
5. Because the source code is freely available
for anyone to examine, security holes and
potential problems are rapidly found and
fixed.
PHP VARIABLES
• Variables are "containers" for storing information.
• Creating (Declaring) PHP Variables
• In PHP, a variable starts with the $ sign, followed by the name of the
variable:
• Example
• <?php
$txt = "Hello world!";
$x = 5;
$y = 10.5;
?>
• Note: When you assign a text value to a variable, put quotes around the
value.
• Note: Unlike other programming languages, PHP has no command for
declaring a variable. It is created the moment you first assign a value to it.
• A variable can have a short name (like x and y) or a more descriptive name
(age, carname, total_volume).
• Rules for PHP variables:
• A variable starts with the $ sign, followed by the name of the variable
• A variable name must start with a letter or the underscore character
• A variable name cannot start with a number
• A variable name can only contain alpha-numeric characters and underscores
(A-z, 0-9, and _ )
• Variable names are case-sensitive ($age and $AGE are two different
variables)
• Output Variables
• The PHP echo statement is often used to output data to the screen. The following
example will show how to output text and a variable:
• Example
• <?php
$txt = "W3Schools.com";
echo "I love $txt!";
?>
• PHP is a Loosely Typed Language
• In the example above, notice that we did not have to tell PHP which data type the
variable is.PHP automatically converts the variable to the correct data type, depending
on its value.
• In other languages such as C, C++, and Java, the programmer must declare the name
and type of the variable before using it.
• PHP Variables Scope
• In PHP, variables can be declared anywhere in the script. The scope of a variable is
the part of the script where the variable can be referenced/used.
• PHP has three different variable scopes:
• local
• global
• static
EMBEDDING PHP CODE IN YOUR WEB PAGES
• One of PHP’s advantages is that you can embed PHP code directly alongside
HTML. For the code to do anything, the page must be passed to the PHP
engine for interpretation. But the web server doesn’t just pass every page;
rather, it passes only those pages identified by a specific file extension
(typically .php)
• Therefore, the engine needs some means to immediately determine which areas of
the page are PHP-enabled. This is logically accomplished by delimiting the PHP
code. There are four delimitation variants.
1.Default Syntax
The default delimiter syntax opens with <?php and concludes with ?>, like this:
If you save this code as test.php and execute it from a PHP-enabled web server, you’ll
see the output shown in Figure.
2.Short-Tags
this syntax forgoes the php reference required in the default syntax. However, to use
this feature, you need to enable PHP’s short_open_tag directive. An example
follows:
<? print "This is another PHP example."; ?>
When short-tags syntax is enabled and you want to quickly escape to and
from PHP to output a bit of dynamic text, you can omit these statements
using an output variation known as short-circuit syntax:
<?="This is another PHP example.";?>
This is functionally equivalent to both of the following variations:
<? echo "This is another PHP example."; ?>
<?php echo "This is another PHP example.";?>
3.Script
Certain editors have historically had problems dealing with PHP’s more
commonly used escape syntax variants. Therefore, support for another mainstream
delimiter variant, <script>, is offered:
<script language="php">
print "This is another PHP example.";
</script>
4.ASP Style
Microsoft ASP pages employ a delimiting strategy similar to that used by PHP,
delimiting static from dynamic syntax by using a predefined character pattern:
opening dynamic syntax with <%, and concluding with %>.
<% print "This is another PHP example."; %>
Embedding Multiple Code Blocks
You can escape to and from PHP as many times as required within a given page. For
instance, the following example is perfectly acceptable:
As you can see, any variables declared in a prior code block are remembered for later
blocks, as is the case with the $date variable in this example.
Commenting Your Code
Whether for your own benefit or for that of somebody tasked with maintaining your
code, the importance of thoroughly commenting your code cannot be overstated.
PHP offers several syntactical variations.
Single-Line C++ Syntax
Comments often require no more than a single line. Because of its brevity,
there is no need to delimit the comment’s conclusion because the newline
(n) character fills this need quite nicely.
PHP supports C++ single-line comment syntax, which is prefaced with a
double slash (//), like this:
Shell Syntax
PHP also supports an alternative to the C++-style single-
line syntax, known as shell syntax, which is prefaced with
a hash mark (#).
<?php # Title: My first PHP script # Author: Jason
Gilmore
echo "This is a PHP program."; ?>
Multiple-Line C Syntax
PHP also offers a multiple-line variant that can open and close the comment on different
lines. Here’s an example:
<?php
/* Processes PayPal payments This script is responsible for processing the
customer's payment via PayPal. accepting the customer's credit card information
and billing address. Copyright 2010 W.J. Gilmore, LLC. */
?>
Outputting Data to the Browser
The print() Statement The print() statement outputs data passed to it . Its
prototype looks like this:
int print(argument)
All of the following are plausible print() statements:
<?php print("<p>I love the summertime.</p>"); ?>
<?php $season = "summertime"; print "<p>I love the $season.</p>"; ?>
<?php print "<p>I love the summertime.</p>"; ?>
All these statements produce identical output:
I love the summertime.
The echo() Statement
Alternatively, you could use the echo() statement for the same purposes as print().
echo()’s prototype looks like this:
void echo(string argument1 [, ...string argumentN])
To use echo(), just provide it with an argument just as was done with print():
echo "I love the summertime.";
Here’s an example:
The sprintf() Statement
The sprintf() statement is functionally identical to printf() except that the output is
assigned to a string rather than rendered to the browser. The prototype follows:
string sprintf(string format [, mixed arguments])
An example follows:
$cost = sprintf("$%.2f", 43.2); // $cost = $43.20
Php intro
Php intro
Php intro
Php intro
Php intro
Php intro
Php intro
Php intro

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

PHP LICTURES ..........
PHP LICTURES ..........PHP LICTURES ..........
PHP LICTURES ..........
 
Php technical presentation
Php technical presentationPhp technical presentation
Php technical presentation
 
PHP .ppt
PHP .pptPHP .ppt
PHP .ppt
 
PHP presentation - Com 585
PHP presentation - Com 585PHP presentation - Com 585
PHP presentation - Com 585
 
Php introduction
Php introductionPhp introduction
Php introduction
 
01 Php Introduction
01 Php Introduction01 Php Introduction
01 Php Introduction
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
PHP programmimg
PHP programmimgPHP programmimg
PHP programmimg
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_master
 
Php
PhpPhp
Php
 
PHP ITCS 323
PHP ITCS 323PHP ITCS 323
PHP ITCS 323
 
web Based Application Devlopment using PHP
web Based Application Devlopment using PHPweb Based Application Devlopment using PHP
web Based Application Devlopment using PHP
 
Php unit i
Php unit iPhp unit i
Php unit i
 
Advanced PHP Web Development Tools in 2015
Advanced PHP Web Development Tools in 2015Advanced PHP Web Development Tools in 2015
Advanced PHP Web Development Tools in 2015
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
PHP - History, Introduction, Summary, Extensions and Frameworks
PHP - History, Introduction, Summary, Extensions and FrameworksPHP - History, Introduction, Summary, Extensions and Frameworks
PHP - History, Introduction, Summary, Extensions and Frameworks
 
PHP Project PPT
PHP Project PPTPHP Project PPT
PHP Project PPT
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
PHP
PHPPHP
PHP
 

Ähnlich wie Php intro

Ähnlich wie Php intro (20)

Php unit i
Php unit i Php unit i
Php unit i
 
1. introduction to php and variable
1. introduction to php and variable1. introduction to php and variable
1. introduction to php and variable
 
Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1
 
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
 
Introduction to PHP.pptx
Introduction to PHP.pptxIntroduction to PHP.pptx
Introduction to PHP.pptx
 
Introduction to PHP.pptx
Introduction to PHP.pptxIntroduction to PHP.pptx
Introduction to PHP.pptx
 
Php
PhpPhp
Php
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Learn PHP Lacture1
Learn PHP Lacture1Learn PHP Lacture1
Learn PHP Lacture1
 
Php
PhpPhp
Php
 
chapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdfchapter 5 Server-Side Scripting (PHP).pdf
chapter 5 Server-Side Scripting (PHP).pdf
 
Welcome to computer programmer 2
Welcome to computer programmer 2Welcome to computer programmer 2
Welcome to computer programmer 2
 
Php
PhpPhp
Php
 
PHP.docx
PHP.docxPHP.docx
PHP.docx
 
Php training in bhubaneswar
Php training in bhubaneswar Php training in bhubaneswar
Php training in bhubaneswar
 
Php training in bhubaneswar
Php training in bhubaneswar Php training in bhubaneswar
Php training in bhubaneswar
 

Mehr von sana mateen

PHP Variables and scopes
PHP Variables and scopesPHP Variables and scopes
PHP Variables and scopessana mateen
 
Php and web forms
Php and web formsPhp and web forms
Php and web formssana mateen
 
Encryption in php
Encryption in phpEncryption in php
Encryption in phpsana mateen
 
Authentication methods
Authentication methodsAuthentication methods
Authentication methodssana mateen
 
Unit 1-subroutines in perl
Unit 1-subroutines in perlUnit 1-subroutines in perl
Unit 1-subroutines in perlsana mateen
 
Unit 1-uses for scripting languages,web scripting
Unit 1-uses for scripting languages,web scriptingUnit 1-uses for scripting languages,web scripting
Unit 1-uses for scripting languages,web scriptingsana mateen
 
Unit 1-strings,patterns and regular expressions
Unit 1-strings,patterns and regular expressionsUnit 1-strings,patterns and regular expressions
Unit 1-strings,patterns and regular expressionssana mateen
 
Unit 1-scalar expressions and control structures
Unit 1-scalar expressions and control structuresUnit 1-scalar expressions and control structures
Unit 1-scalar expressions and control structuressana mateen
 
Unit 1-perl names values and variables
Unit 1-perl names values and variablesUnit 1-perl names values and variables
Unit 1-perl names values and variablessana mateen
 

Mehr von sana mateen (20)

Files
FilesFiles
Files
 
PHP Variables and scopes
PHP Variables and scopesPHP Variables and scopes
PHP Variables and scopes
 
Php and web forms
Php and web formsPhp and web forms
Php and web forms
 
Mail
MailMail
Mail
 
Files in php
Files in phpFiles in php
Files in php
 
File upload php
File upload phpFile upload php
File upload php
 
Regex posix
Regex posixRegex posix
Regex posix
 
Encryption in php
Encryption in phpEncryption in php
Encryption in php
 
Authentication methods
Authentication methodsAuthentication methods
Authentication methods
 
Xml schema
Xml schemaXml schema
Xml schema
 
Xml dtd
Xml dtdXml dtd
Xml dtd
 
Xml dom
Xml domXml dom
Xml dom
 
Xhtml
XhtmlXhtml
Xhtml
 
Intro xml
Intro xmlIntro xml
Intro xml
 
Dom parser
Dom parserDom parser
Dom parser
 
Unit 1-subroutines in perl
Unit 1-subroutines in perlUnit 1-subroutines in perl
Unit 1-subroutines in perl
 
Unit 1-uses for scripting languages,web scripting
Unit 1-uses for scripting languages,web scriptingUnit 1-uses for scripting languages,web scripting
Unit 1-uses for scripting languages,web scripting
 
Unit 1-strings,patterns and regular expressions
Unit 1-strings,patterns and regular expressionsUnit 1-strings,patterns and regular expressions
Unit 1-strings,patterns and regular expressions
 
Unit 1-scalar expressions and control structures
Unit 1-scalar expressions and control structuresUnit 1-scalar expressions and control structures
Unit 1-scalar expressions and control structures
 
Unit 1-perl names values and variables
Unit 1-perl names values and variablesUnit 1-perl names values and variables
Unit 1-perl names values and variables
 

Kürzlich hochgeladen

IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 

Kürzlich hochgeladen (20)

IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 

Php intro

  • 2. What is PHP? 1. PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. 2. PHP is a widely-used, free, and efficient alternative to competitors such as Microsoft's ASP. 3. PHP is an acronym for "PHP: Hypertext Preprocessor" 4. PHP is a widely-used, open source scripting language 5. PHP scripts are executed on the server 6. PHP is free to download and use What is a PHP File? 1. PHP files can contain text, HTML, CSS, JavaScript, and PHP code 2. PHP code are executed on the server, and the result is returned to the browser as plain HTML 3. PHP files have extension ".php"
  • 3. What Can PHP Do? 1. PHP can generate dynamic page content 2. PHP can create, open, read, write, delete, and close files on the server 3. PHP can collect form data 4. PHP can send and receive cookies 5. PHP can add, delete, modify data in your database 6. PHP can be used to control user-access 7. PHP can encrypt data 8. With PHP you are not limited to output HTML. You can output images, PDF files, and even Flash movies. You can also output any text, such as XHTML and XML. • Why PHP? 1. PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.) 2. PHP is compatible with almost all servers used today (Apache, IIS, etc.) 3. PHP supports a wide range of databases 4. PHP is free. Download it from the official PHP resource: www.php.net 5. PHP is easy to learn and runs efficiently on the server side
  • 4. PHP INSTALLATION • What Do I Need? 1. To start using PHP, you can: 2. Find a web host with PHP and MySQL support 3. Install a web server on your own PC, and then install PHP and MySQL • Use a Web Host With PHP Support 1. If your server has activated support for PHP you do not need to do anything. 2. Just create some .php files, place them in your web directory, and the server will automatically parse them for you. 3. You do not need to compile anything or install any extra tools. 4. Because PHP is free, most web hosts offer PHP support. • Set Up PHP on Your Own PC 1. However, if your server does not support PHP, you must: 2. install a web server 3. install PHP 4. install a database, such as MySQL 5. The official PHP website (PHP.net) has installation instructions for PHP: http://php.net/manual/en/install.php
  • 5. INSTALLATION PREREQUISITES • Downloading Apache • These days, Apache is packaged with all mainstream Linux distributions. So if you’re using one of these platforms, chances are quite good you already have it installed or can easily install it through your distribution’s packaging service (e.g., by running the apt-get command on Ubuntu). • If you’re running Windows and would like to use Apache, then download the latest stable Windows binary located within the binaries/win32 directory. Two binary versions are available: one containing additional SSL-related capabilities and one lacking these capabilities. It is suggested choosing the non-SSL capable version for development purposes. • Downloading PHP • Windows zip package: If you plan to use PHP in conjunction with Apache on Windows, you should download this distribution because it’s the focus of the later installation instructions. • Windows installer: This version offers a convenient Windows installer interface for installing and configuring PHP, plus support for automatically configuring the IIS, PWS, and Xitami servers.
  • 6. PHP SYNTAX • A PHP script is executed on the server, and the plain HTML result is sent back to the browser. • Basic PHP Syntax • A PHP script can be placed anywhere in the document. • A PHP script starts with <?php and ends with ?>: • <?php // PHP code goes here ?> • The default file extension for PHP files is ".php". • A PHP file normally contains HTML tags, and some PHP scripting code.
  • 7. PHP FEATURES • Practicality • After all, Lerdorf’s original intention was not to design an entirely new language, but to resolve a problem that had no readily available solution. • For instance, a useful PHP script can consist of as little as one line; unlike C, there is no need for the mandatory inclusion of libraries. • For example, the following represents a complete PHP script, the purpose of which is to output the current date, in this case one formatted like September 23, 2007: <?php echo date("F j, Y"); ?> • PHP is a loosely typed language, meaning there is no need to explicitly create, typecast, or destroy a variable, although you are not prevented from doing so. • Power • Create and manipulate Adobe Flash and Portable Document Format (PDF) files. • Parse even the most complex of strings using the POSIX and Perl-based regular expression libraries. • Authenticate users against login credentials stored in flat files, databases, and even Microsoft’s Active Directory. • Communicate with a wide variety of protocols, including LDAP, IMAP, POP3, NNTP, and DNS, among others.
  • 8. Possibility 1. For example, consider PHP’s array of database support options. 2. Native support is offered for more than 25 database products, including IBM DB2, mSQL, Microsoft SQL Server, MySQL, Oracle, PostgreSQL, Solid, Sybase, Unix dbm, and Velocis 3. PHP’s flexible string-parsing capabilities offer users of differing skill sets the opportunity to not only immediately begin performing complex string operations but also to quickly port programs of similar functionality (such as Perl and Python) over to PHP Price 1. PHP is available free of charge! Since its inception, PHP has been without usage, modification, and redistribution restrictions. 2. Free of licensing restrictions imposed by most commercial products: 3. Although some discrepancies do exist among license variants, users are largely free to modify, redistribute, and integrate the software into other products. 4. Open development and auditing process 5. Because the source code is freely available for anyone to examine, security holes and potential problems are rapidly found and fixed.
  • 9. PHP VARIABLES • Variables are "containers" for storing information. • Creating (Declaring) PHP Variables • In PHP, a variable starts with the $ sign, followed by the name of the variable: • Example • <?php $txt = "Hello world!"; $x = 5; $y = 10.5; ?> • Note: When you assign a text value to a variable, put quotes around the value. • Note: Unlike other programming languages, PHP has no command for declaring a variable. It is created the moment you first assign a value to it. • A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). • Rules for PHP variables: • A variable starts with the $ sign, followed by the name of the variable • A variable name must start with a letter or the underscore character • A variable name cannot start with a number • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ) • Variable names are case-sensitive ($age and $AGE are two different variables)
  • 10. • Output Variables • The PHP echo statement is often used to output data to the screen. The following example will show how to output text and a variable: • Example • <?php $txt = "W3Schools.com"; echo "I love $txt!"; ?> • PHP is a Loosely Typed Language • In the example above, notice that we did not have to tell PHP which data type the variable is.PHP automatically converts the variable to the correct data type, depending on its value. • In other languages such as C, C++, and Java, the programmer must declare the name and type of the variable before using it. • PHP Variables Scope • In PHP, variables can be declared anywhere in the script. The scope of a variable is the part of the script where the variable can be referenced/used. • PHP has three different variable scopes: • local • global • static
  • 11. EMBEDDING PHP CODE IN YOUR WEB PAGES • One of PHP’s advantages is that you can embed PHP code directly alongside HTML. For the code to do anything, the page must be passed to the PHP engine for interpretation. But the web server doesn’t just pass every page; rather, it passes only those pages identified by a specific file extension (typically .php) • Therefore, the engine needs some means to immediately determine which areas of the page are PHP-enabled. This is logically accomplished by delimiting the PHP code. There are four delimitation variants.
  • 12. 1.Default Syntax The default delimiter syntax opens with <?php and concludes with ?>, like this: If you save this code as test.php and execute it from a PHP-enabled web server, you’ll see the output shown in Figure. 2.Short-Tags this syntax forgoes the php reference required in the default syntax. However, to use this feature, you need to enable PHP’s short_open_tag directive. An example follows: <? print "This is another PHP example."; ?>
  • 13. When short-tags syntax is enabled and you want to quickly escape to and from PHP to output a bit of dynamic text, you can omit these statements using an output variation known as short-circuit syntax: <?="This is another PHP example.";?> This is functionally equivalent to both of the following variations: <? echo "This is another PHP example."; ?> <?php echo "This is another PHP example.";?> 3.Script Certain editors have historically had problems dealing with PHP’s more commonly used escape syntax variants. Therefore, support for another mainstream delimiter variant, <script>, is offered: <script language="php"> print "This is another PHP example."; </script> 4.ASP Style Microsoft ASP pages employ a delimiting strategy similar to that used by PHP, delimiting static from dynamic syntax by using a predefined character pattern: opening dynamic syntax with <%, and concluding with %>. <% print "This is another PHP example."; %>
  • 14. Embedding Multiple Code Blocks You can escape to and from PHP as many times as required within a given page. For instance, the following example is perfectly acceptable: As you can see, any variables declared in a prior code block are remembered for later blocks, as is the case with the $date variable in this example. Commenting Your Code Whether for your own benefit or for that of somebody tasked with maintaining your code, the importance of thoroughly commenting your code cannot be overstated. PHP offers several syntactical variations.
  • 15. Single-Line C++ Syntax Comments often require no more than a single line. Because of its brevity, there is no need to delimit the comment’s conclusion because the newline (n) character fills this need quite nicely. PHP supports C++ single-line comment syntax, which is prefaced with a double slash (//), like this: Shell Syntax PHP also supports an alternative to the C++-style single- line syntax, known as shell syntax, which is prefaced with a hash mark (#). <?php # Title: My first PHP script # Author: Jason Gilmore echo "This is a PHP program."; ?>
  • 16. Multiple-Line C Syntax PHP also offers a multiple-line variant that can open and close the comment on different lines. Here’s an example: <?php /* Processes PayPal payments This script is responsible for processing the customer's payment via PayPal. accepting the customer's credit card information and billing address. Copyright 2010 W.J. Gilmore, LLC. */ ?> Outputting Data to the Browser The print() Statement The print() statement outputs data passed to it . Its prototype looks like this: int print(argument) All of the following are plausible print() statements: <?php print("<p>I love the summertime.</p>"); ?> <?php $season = "summertime"; print "<p>I love the $season.</p>"; ?> <?php print "<p>I love the summertime.</p>"; ?> All these statements produce identical output: I love the summertime.
  • 17. The echo() Statement Alternatively, you could use the echo() statement for the same purposes as print(). echo()’s prototype looks like this: void echo(string argument1 [, ...string argumentN]) To use echo(), just provide it with an argument just as was done with print(): echo "I love the summertime."; Here’s an example: The sprintf() Statement The sprintf() statement is functionally identical to printf() except that the output is assigned to a string rather than rendered to the browser. The prototype follows: string sprintf(string format [, mixed arguments]) An example follows: $cost = sprintf("$%.2f", 43.2); // $cost = $43.20