SlideShare a Scribd company logo
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

More Related Content

What's hot

PHP LICTURES ..........
PHP LICTURES ..........PHP LICTURES ..........
PHP LICTURES ..........
Rashid Ahmad
 
Php technical presentation
Php technical presentationPhp technical presentation
Php technical presentation
dharmendra kumar dhakar
 
PHP presentation - Com 585
PHP presentation - Com 585PHP presentation - Com 585
PHP presentation - Com 585
jstout007
 
01 Php Introduction
01 Php Introduction01 Php Introduction
01 Php Introduction
Geshan Manandhar
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
ShahRushika
 
PHP programmimg
PHP programmimgPHP programmimg
PHP programmimg
Sharbani Bhattacharya
 
Php tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPhp tutorial from_beginner_to_master
Php tutorial from_beginner_to_masterPrinceGuru MS
 
PHP ITCS 323
PHP ITCS 323PHP ITCS 323
PHP ITCS 323
Sleepy Head
 
web Based Application Devlopment using PHP
web Based Application Devlopment using PHPweb Based Application Devlopment using PHP
web Based Application Devlopment using PHP
maccodder
 
Php unit i
Php unit iPhp unit i
Php unit i
BagavathiLakshmi
 
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
iScripts
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
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 FrameworksRoyston Olivera
 
PHP Project PPT
PHP Project PPTPHP Project PPT
PHP Project PPT
Pankil Agrawal
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
SHARANBAJWA
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
Meetendra Singh
 
PHP
PHPPHP

What's hot (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
 

Similar to Php intro

Php unit i
Php unit i Php unit i
Php unit i
prakashvs7
 
1. introduction to php and variable
1. introduction to php and variable1. introduction to php and variable
1. introduction to php and variable
NurAliaAqilaMuhalis
 
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
Mohd Harris Ahmad Jaal
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
sushil kumar
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
Nguyễn Hoà
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
vigneswaran54
 
How PHP works
How PHP works How PHP works
Php tutorial
Php tutorialPhp tutorial
Php tutorialNiit
 
Introduction to PHP.pptx
Introduction to PHP.pptxIntroduction to PHP.pptx
Introduction to PHP.pptx
MarianJRuben
 
Introduction to PHP.pptx
Introduction to PHP.pptxIntroduction to PHP.pptx
Introduction to PHP.pptx
SherinRappai
 
Chapter 1
Chapter 1Chapter 1
Chapter 1Uma Sam
 
Learn PHP Lacture1
Learn PHP Lacture1Learn PHP Lacture1
Learn PHP Lacture1ADARSH BHATT
 
Php
PhpPhp
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
burasyacob012
 
Welcome to computer programmer 2
Welcome to computer programmer 2Welcome to computer programmer 2
Welcome to computer programmer 2
MLG College of Learning, Inc
 
PHP.docx
PHP.docxPHP.docx
PHP.docx
NithiyaNithi2
 
Php training in bhubaneswar
Php training in bhubaneswar Php training in bhubaneswar
Php training in bhubaneswar
litbbsr
 
Php training in bhubaneswar
Php training in bhubaneswar Php training in bhubaneswar
Php training in bhubaneswar litbbsr
 

Similar to 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
 

More from sana mateen

Files
FilesFiles
PHP Variables and scopes
PHP Variables and scopesPHP Variables and scopes
PHP Variables and scopes
sana mateen
 
Php and web forms
Php and web formsPhp and web forms
Php and web forms
sana mateen
 
Mail
MailMail
Files in php
Files in phpFiles in php
Files in php
sana mateen
 
File upload php
File upload phpFile upload php
File upload php
sana mateen
 
Regex posix
Regex posixRegex posix
Regex posix
sana mateen
 
Encryption in php
Encryption in phpEncryption in php
Encryption in php
sana mateen
 
Authentication methods
Authentication methodsAuthentication methods
Authentication methods
sana mateen
 
Xml schema
Xml schemaXml schema
Xml schema
sana mateen
 
Xml dtd
Xml dtdXml dtd
Xml dtd
sana mateen
 
Xml dom
Xml domXml dom
Xml dom
sana mateen
 
Xhtml
XhtmlXhtml
Intro xml
Intro xmlIntro xml
Intro xml
sana mateen
 
Dom parser
Dom parserDom parser
Dom parser
sana mateen
 
Unit 1-subroutines in perl
Unit 1-subroutines in perlUnit 1-subroutines in perl
Unit 1-subroutines in perl
sana 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 scripting
sana 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 expressions
sana 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 structures
sana 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 variables
sana mateen
 

More from 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
 

Recently uploaded

DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
Kamal Acharya
 
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
dxobcob
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 

Recently uploaded (20)

DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
 
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
一比一原版(Otago毕业证)奥塔哥大学毕业证成绩单如何办理
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 

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