WTA8 PHP - Hypertext Preprocessor(PHP PHP is a server-side...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Hypertext Preprocessor (PHP) PHP is a server-side scripting language. Syntax Variables, Constants, Conditions, Loops File Inclusions Forms 1 What is PHP b PHP is known as a server-sided language. That's because the PHP doesn't get executed on your computer, but on the computer you requested the page from. The results are then handed over to you, and displayed in your browser. b On the client side when the user views the code, the php code is converted into html tags. Thus the client cannot see the php code. 2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Why do we need PHP b PHP is probably the most popular scripting language on the web. b It is used to enhance web pages. With PHP, you can do things like create username and password login pages, check details from a form, create forums, picture galleries, surveys, and a whole lot more. b If you've come across a web page that ends in PHP, then the author has written some programming code to liven up the plain, old HTML. 3 4 Introduction b PHP stands for P HP: H ypertext P reprocessor b PHP is a server-side scripting language, like ASP b PHP scripts are executed on the server b PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.) b PHP is an open source software b PHP is free to download and use b PHP files can contain text, HTML tags and scripts b PHP files are returned to the browser as plain HTML b PHP files have a file extension of ".php", ".php3", or ".phtml"
Background image of page 2
3 PHP Syntax b PHP code is executed on the server, and the plain HTML result is sent to the browser. b A PHP scripting block always starts with <?php and ends with ?> . A PHP scripting block can be placed anywhere in the document. b Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to distinguish one set of instructions from another. 5 Sample Program <html> <body> <?php echo "Hello World"; ?> </body> </html> 6 Statements like echo & print are used for unformatted output & printf() can be used for formatted output.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Comments in PHP b 7 <html> <body> <?php //This is a comment /* This is a comment block */ ?> </body> </html> Variables b Variables are used for storing values, like text strings, numbers or arrays. b All variables in PHP start with a $ sign symbol. b Syntax : $var_name = value; 8
Background image of page 4
5 Constants <?php define(“STRCONSTANT”,”This is a String Constant”); define(“INTCONSTANT”,1000); define(“FLTCONSTANT”,2500.25); echo STRCONSTANT; echo ‘<BR>’; echo INTCONSTANT; echo ‘<BR>’; echo FLTCONSTANT; echo ‘<BR>’; ?> 9 OUTPUT: This is a String Constant 1000 2500.25 PHP is a Loosely Typed Language b In PHP, a variable does not need to be declared before adding a value to it. b
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/04/2011 for the course IT 103 taught by Professor Php during the Spring '11 term at University of Mumbai.

Page1 / 43

WTA8 PHP - Hypertext Preprocessor(PHP PHP is a server-side...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online