PHP : Hypertext Preprocessor

Slides:



Advertisements
Similar presentations
PHP I.
Advertisements

Session 1 & 2BBK P1 Module5-May-2007 : [‹#›] PHP: The Basics.
P1PMF Split1 QBASIC. P1PMF Split2QBasic Command Prompt Will launch the emulator DOS operating system? Press Alt + Enter to display the widescreen.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
1 Chapter 5 – Handling HTML Controls in Web Pages spring into PHP 5 by Steven Holzner Slides were developed by Jack Davis College of Information Science.
IST 221 Internet Concepts and Applications Introduction to PHP.
Introduction to scripting
. If the PHP server is an server or is aware of which server is the server, then one can write code that s information. –For example,
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
PHP Workshop ‹#› PHP: The Basics. PHP Workshop ‹#› What is it? PHP is a scripting language commonly used on web servers. –Stands for “PHP: Hypertext Preprocessor”
PHP: Hypertext Processor Fred Durao
ALBERT WAVERING BOBBY SENG. Week Whatever: PHP  Announcements/questions/complaints.
CSC 318 WEB APPLICATION DEVELOPMENT.  Introduction to Server Scripting language  Client VS Server  Introduction to PHP  PHP Files and Syntax  Function.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
PHP Overview CS PHP PHP = PHP: Hypertext Preprocessor Server-side scripting language that may be embedded into HTML One goal is to get PHP files.
1 Introduction to PHP. 2 What is this “PHP” thing? Official description: “PHP, which stands for "PHP: Hypertext Preprocessor" is a widely-used Open Source.
Web forms in PHP Forms Recap  Way of allowing user interaction  Allows users to input data that can then be processed by a program / stored in a back-end.
Server- Side technologies Client-side vs. Server-side scripts PHP basic ASP.NET basic ColdFusion.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Form Handling.
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
Copyright © Curt Hill PhP History and Introduction.
(c) Manzur Ashraf, Short course, KFUPM PHP & MySQL 1 Basic PHP Class 2.
Chapter 4 – The Building Blocks Data Types Literals Variables Constants.
PHP. Why should we learn web programming? No need write socket programming. - You can forget TCP/IP & OSI layers. - Web server handles socket tasks for.
IDK0040 Võrgurakendused I harjutus 06: PHP: Introduction Deniss Kumlander.
INTERNET APPLICATION DEVELOPMENT For More visit:
Week 7. Lecture 3 PHP Forms. PHP forms In part 2 of this course, we discussed html forms, php form is similar. Lets do a quick recap of the things we.
Nael Alian Introduction to PHP
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
2440: 211 Interactive Web Programming Expressions & Operators.
Mastering Char to ASCII AND DOING MORE RELATED STRING MANIPULATION Why VB.Net ?  The Language resembles Pseudocode - good for teaching and learning fundamentals.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
3 - Variables Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
DHTML AND JAVASCRIPT Genetic Computer School LESSON 5 INTRODUCTION JAVASCRIPT G H E F.
Variables and ConstantstMyn1 Variables and Constants PHP stands for: ”PHP: Hypertext Preprocessor”, and it is a server-side programming language. Special.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
PHP. What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
PHP Form Introduction Getting User Information Text Input.
Introduction to PHP Advanced Database System Lab no.1.
What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server PHP supports.
Introduction to Web Programming. Introduction to PHP What is PHP? What is a PHP File? What is MySQL? Why PHP? Where to Start?
Week 4 PHP H ypertext P reprocessor Reference : Official Site :
Strings, output, quotes and comments
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Server-Side Scripting with PHP ISYS 475. PHP Manual Website
הרצאה 4. עיבוד של דף אינטרנט דינמי מתוך Murach’s PHP and MySQL by Joel Murach and Ray Harris.  דף אינטרנט דינמי משתנה עפ " י הרצת קוד על השרת, יכול להשתנות.
IT ELECTIVE 2.  Web server Can refer to either the hardware (the computer) or the software (the computer application) that helps to deliver content that.
CSD 340 (Blum)1 Starting JavaScript Homage to the Homage to the Square.
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
Basic ActionScript and PHP Cis 126. Getting Started set up a basic folder structure so we can keep our files organized. Mirror this structure on your.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
PHP Syntax You cannot view the PHP source code by selecting "View source" in the browser - you will only see the output from the PHP file, which is plain.
PHP Form Processing * referenced from
Project 4: Working with Variables Essentials for Design JavaScript Level One Michael Brooks.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
CGS 3066: Web Programming and Design Spring 2016 PHP.
Linux Administration Working with the BASH Shell.
PHP (PHP: Hypertext Preprocessor)
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
Variables, Expressions, and IO
PHP Introduction.
Intro to PHP & Variables
PHP: Security issues FdSc Module 109 Server side scripting and
23 PHP.
Presentation transcript:

PHP : Hypertext Preprocessor

What is PHP for? Unlike JavaScript which is a client-side script language, PHP is a server side script PHP is processed on the server, therefore you can not use the View/Source menu command to view someone else's PHP code. Finally someone is protecting my code.  PHP programs/scripts perform several basic operations Obtain data from a user Perform computations Access and manipulate data stored in files and databases Display data so that a user can view it.

My first PHP script Inside the regular html file You include the following tag <?php // code here ?> Make sure you save it as .php

My first PHP script: pex1.php echo 'Hello World'; echo '<br /> <h1> Hello World</h1>'; echo '<em> Hello World </em> '; ?> ! Before you upload to your server, make sure you make a directory call php so we know where to look for your code.

PHP Script Note that inside the echo command, it is similar to writing code on regular HTML. Remember that the PHP script will be pre-processed. Therefore when you try and view the code, it does not have the php scripts but rather the final processed text. Therefore, you have to upload it to the server to see how it looks like. If you preview, you will see garbage.

Variables Similar to JavaScript, you can work with variables. Variables must begin with a dollar sign ($). You can generally name a variable anything you like as long as it begins with a $ and a letter or a underscore “_”. For example, a good variable name might be $firstName or $first_name. DO NOT include blank spaces in a variable name. If you choose to make a variable name out of two or more words, I recommend using an underscore ( _ ) between the two words or capitalizing the second word so the variable name is easier to read.

Variables A variable can store integers as in $num = 5; or it can store a decimal number as in $price = 19.99; or it can store a string (i.e. a word or phrase) as in $name = 'John Doe'; Variables in php do not need to be declared with specific data types

Variables You can use the dot operator ( . ) to concatenate two strings together into one string. Remember to add a blank space if necessary with ' ' or " ". For example the following code segment will result in the name "John Doe" being stored in the variable $wholeName. $firstName = 'John'; $lastName = 'Doe'; $wholeName = $firstName . ' ' . $lastName;

Using comments Especially when you are still new to the language it is good to put comments around your code Three ways to include a PHP comment Anything typed to the right of two forward slashes // is a comment as in // this is a comment Anything enclosed within the symbols /* and */ is a comment. This kind of comment can extend to multiple lines of code /* this is a comment this is still a comment this is a comment */ Anything typed to the right of a pound symbol ( # ) is a comment # this is a comment

Process data from a “form” PHP to access data submitted by a form PHP creates an array using data sent using a POST action request. To assess variables in a POST request, you can use the $_POST array. e.g. <input type="text" name="val1" value=""> $_POST['val1'] will have the value of what you store in the textbox above.

Let us put it together using forms pex2.html & pex2.php <head> </head> <body> <form action= "pex2.php" method="post"> Enter your message: <input type="text" name="msg" size="30"> <input type="submit" value="Send"> </form></body> </html> pex2.php <?php $input=$_POST['msg']; echo "You said: $input"; ?>

pex3.html, pex3.php Error Message 1 Error Message 2 Correct Response Create a form that allows you to enter your first and last name. Check that both names are not empty using PHP using strlen(). The command trim(variable_name) trims any spaces in the beginning or end and returns the new string. The command strlen(variable_name) counts the number of characters in the variable_name. So you can combine strlen(trim(variable_name) to count the number of characters omitting any spaces in front or back. The if (condition) works the same as JavaScript: eg. if ($a == $b) { echo (‘<b>HELP</b>’); }