Introduction to Web programming

Slides:



Advertisements
Similar presentations
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
Advertisements

IST 221 Internet Concepts and Applications Introduction to PHP.
1 CS428 Web Engineering Lecture 18 Introduction (PHP - I)
Php. What is PHP? PHP is an acronym for "PHP Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on.
PHPPHP What is PHP? Hypertext Pre-processor (PHPs) is a server- side scripting language In early versions, PHP stand for Personal Home Page. server-side.
PHP By Dr. Syed Noman Hasany. PHP PHP was originally created by Rasmus Lerdorf in PHP stands for PHP: Hypertext Preprocessor (a recursive acronym).
CSC 318 WEB APPLICATION DEVELOPMENT.  Introduction to Server Scripting language  Client VS Server  Introduction to PHP  PHP Files and Syntax  Function.
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.
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:
Nael Alian Introduction to PHP
IST 210: PHP BASICS IST 210: Organization of Data IST210 1.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
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.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
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?
הרצאה 4. עיבוד של דף אינטרנט דינמי מתוך Murach’s PHP and MySQL by Joel Murach and Ray Harris.  דף אינטרנט דינמי משתנה עפ " י הרצת קוד על השרת, יכול להשתנות.
CHAPTER 6 Introduction to PHP5 Part I อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
PHP Introduction PHP is a server-side scripting language.
 A PHP script can be placed anywhere in the document.  A PHP script starts with  The default file extension for PHP files is ".php".  A PHP file normally.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
 Before you continue you should have a basic understanding of the following:  HTML  CSS  JavaScript.
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.
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,
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 1 Introduction to PHP Hypertext Preprocessor - PHP.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
CGS 3066: Web Programming and Design Spring 2016 PHP.
By bscshelp.com 1.  It is a group assignment.  Complete Website design Using Html and Css.  Due date: 10 th December, 2014 (Hard Deadline) 2.
PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used, free, and efficient alternative.
Introduction to PHP. PHP Origins Rasmus LerdorfRasmus Lerdorf (born Greenland, ed Canada) PHP originally abbreviation for ‘Personal Home Pages’, now ‘PHP.
PHP Basics and Syntax Lesson 3 ITBS2203 E-Commerce for IT.
PHP using MySQL Database for Web Development (part II)
Web Database Programming Using PHP
Web Systems & Technologies
CGS 3066: Web Programming and Design Spring 2017
Introduction to Dynamic Web Programming
Chapter 6 JavaScript: Introduction to Scripting
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Web Database Programming Using PHP
PHP 5 Syntax.
PHP (PHP: Hypertext Preprocessor)
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
PHP Rasmus Lerdorf.
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
BASIC PHP and MYSQL Edward S. Flores.
PHP Variables 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.
Server-Side Application and Data Management IT IS 3105 (Spring 2010)
PHP Introduction.
Intro to PHP & Variables
PHP.
Embedded PHP in HTML 5 & Strings in PHP
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Web Programming Language
Intro to PHP.
Tutorial 6 PHP & MySQL Li Xu
Tutorial 10: Programming with javascript
Introduction to PHP.
PHP an introduction.
Introduction to Web programming
PHP By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and.
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Web Application Development Using PHP
Contact PSK Technologies Pvt. Ltd IT Company Address - Plot No-780, Near Durga Temple, Katol Road Chaoni, Nagpur-13.
Presentation transcript:

Introduction to Web programming 0731213

Lecture 1 What is PHP?

What is PHP? What is PHP? PHP is an acronym for "PHP: Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on the server PHP is free to download and use PHP is an amazing and popular language! It is powerful enough to be at the core of the biggest blogging system on the web (WordPress)! It is deep enough to run the largest social network (Facebook)! It is also easy enough to be a beginner's first server side language!

A Simple HTML Document This prints the sentence “My first PHP script” on the screen <!DOCTYPE html> <html> <body> <?php echo "My first PHP script!"; ?> </body> </html>

What is PHP File? PHP files can contain text, HTML, CSS, JavaScript, and PHP code PHP code are executed on the server, and the result is returned to the browser as plain HTML PHP files have extension ".php"

What Can PHP Do? PHP can generate dynamic page content PHP can create, open, read, write, delete, and close files on the server PHP can collect form data PHP can send and receive cookies PHP can add, delete, modify data in your database PHP can be used to control user-access PHP can encrypt data

Why PHP? PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.) PHP is compatible with almost all servers used today (Apache, IIS, etc.) PHP supports a wide range of databases PHP is free. PHP is easy to learn and runs efficiently on the server side

What Do I Need? To start using PHP install a web server on your own PC, and then install PHP and MySQL There are some excellent all-in-one Windows distributions that contain Apache, PHP, MySQL and other applications in a single installation file, e.g. XAMPP, WampServer and Web.Developer. XAMPP is a completely free, easy to install Apache-MySQL-PHP-PERL-PEAR framework. The XAMPP open source package has been set up to be incredibly easy to install and to use. XAMPP saves time and effort and provides the software support for web frameworks like Drupal, Joomla, Moodle, or wikiMedia on any Windows PC.

How to Install XAMPP for Windows Step 1: In your web browser, go to  https://www.apachefriends.org/index.html

How to Install XAMPP for Windows Step 2: Click on the download link for XAMPP.

How to Install XAMPP for Windows Step 3: When prompted for the download, click "Save" and wait for your download to finish.

How to Install XAMPP for Windows Step 4: Open CD or DVD drive from My Computer. Install the program, and click on "Run."

How to Install XAMPP for Windows Step 5: Accept the default settings. A command will open and offer an initial installation prompt. Just hit the Enter key, and accept the default settings.

How to Install XAMPP for Windows Step 6: When your installation is complete, exit the command window by hitting the Enter key.

How to Install XAMPP for Windows Step 7: Start the XAMPP Control Panel.

How to Install XAMPP for Windows Step 8: Start the Apache and MySQL components. You can also start the other components, if you plan to use them.

How to Install XAMPP for Windows Step 9: Verify the Apache install, by clicking on the Apache administrative link in the Control Panel.

How to Install XAMPP for Windows Step 10: Verify the MySQL installation, by clicking on the MySQL administrative link in the XAMPP Control Panel.

Run a PHP program in XAMPP Server Step 1: Install XAMPP. Step 2: Assume you installed xampp in C Drive. Go to: C:\xampp\htdocs Step 3: Create your own folder, name it for example as example. Step 4: Now create your first php program in xampp and name it as “page1.php”: <!DOCTYPE html> <html> <body> <?php echo "My first PHP script!"; ?> </body> </html>

Run a PHP program in XAMPP Server Step 5: Now type the following on browser: http://localhost/example/ Below screenshot shows php files created under folder “example”

Run a PHP program in XAMPP Server Step 6: Click on “page1.php” and it will show the following:

Create your website home page Create your home page under the folder “example” and name it as “index.php” or “default.php”. Now type the following on browser: http://localhost/example/ Below screenshot shows the home page for your website: <!DOCTYPE html> <html> <body> <?php echo “index or default page"; ?> </body> </html>

Lecture 2 PHP basics (1)

Basic PHP Syntax A PHP script can be placed anywhere in the document. A PHP script starts with <?php and ends with ?>: The default file extension for PHP files is ".php". A PHP file normally contains HTML tags, and some PHP scripting code. <?php // PHP code goes here ?>

Basic PHP Syntax Below, we have an example of a simple PHP file, with a PHP script that uses a built-in PHP function "echo" to output the text "Hello World!" on a web page: <!DOCTYPE html> <html> <body> <h1>My first PHP page</h1> <?php echo "Hello World!"; ?> </body> </html>

Comments in PHP A comment in PHP code is a line that is not read/executed as part of the program. Its only purpose is to be read by someone who is looking at the code. PHP supports several ways of commenting: <?php // This is a single-line comment # This is also a single-line comment /* This is a multiple-lines comment block that spans over multiple lines */ // You can also use comments to leave out parts of a code line $x = 5 /* + 15 */ + 5; echo $x; ?>

PHP Case Sensitivity In PHP, all keywords (e.g. if, else, while, echo, etc.), classes, functions, and user- defined functions are NOT case-sensitive. In the example below, all three echo statements below are legal (and equal): However; all variable names are case-sensitive. In the example below, only the first statement will display the value of the $color variable (this is because $color, $COLOR, and $coLOR are treated as three different variables): <?php ECHO "Hello World!<br>"; echo "Hello World!<br>"; EcHo "Hello World!<br>"; ?> <?php $color = "red"; echo "My car is " . $color . "<br>"; echo "My house is " . $COLOR . "<br>"; echo "My boat is " . $coLOR . "<br>"; ?>

PHP Variables Variables are "containers" for storing information. In PHP, a variable starts with the $ sign, followed by the name of the variable: After the execution of the statements above, the variable $txt will hold the value Hello world!, the variable $x will hold the value 5, and the variable $y will hold the value 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. <?php $txt = "Hello world!"; $x = 5; $y = 10.5; ?>

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 using echo statement : The following example will produce the same output as the example above: The following example will output the sum of two variables: <?php $txt = "W3Schools.com"; echo "I love $txt!"; ?> <?php $txt = "W3Schools.com"; echo "I love " . $txt . "!"; ?> <?php $x = 5; $y = 4; echo $x + $y; ?>

Lecture 3 PHP basics (2)

PHP Data Types Variables can store data of different types, and different data types can do different things. PHP supports the following data types: String Integer Float (floating point numbers - also called double) Boolean Array Object NULL Resource

PHP String A string is a sequence of characters, like "Hello world!". A string can be any text inside quotes. You can use single or double quotes: <?php $x = "Hello world!"; $y = 'Hello world!'; echo $x; echo "<br>"; echo $y; ?>

PHP String PHP String Functions Get The Length of a String: The PHP strlen() function returns the length of a string. Count The Number of Words in a String: The PHP str_word_count() function counts the number of words in a string: Reverse a String: The PHP strrev() function reverses a string <?php echo strlen("Hello world!"); // outputs 12 ?> <?php echo str_word_count("Hello world!"); // outputs 2 ?> <?php echo strrev("Hello world!"); // outputs !dlrow olleH ?>

PHP String PHP String Functions Search For a Specific Text Within a String: The PHP strpos() function searches for a specific text within a string. If a match is found, the function returns the character position of the first match. If no match is found, it will return FALSE. Replace Text Within a String: The PHP str_replace() function replaces some characters with some other characters in a string. <?php echo strpos("Hello world!", "world"); // outputs 6 ?> <?php echo str_replace("world", "Dolly", "Hello world!"); // outputs Hello Dolly! ?>

PHP Integer An integer data type is a non-decimal number between -2,147,483,648 and 2,147,483,647. <?php $x = 5985; var_dump($x); ?>

PHP Float A float (floating point number) is a number with a decimal point or a number in exponential form. In the following example $x is a float. The PHP var_dump() function returns the data type and value: <?php $x = 10.365; var_dump($x); ?>

PHP Boolean A Boolean represents two possible states: TRUE or FALSE. Booleans are often used in conditional testing. <?php $x = true; $y = false; ?>

PHP Array An array stores multiple values in one single variable. In the following example $cars is an array. The PHP var_dump() function returns the data type and value: <?php $cars = array("Volvo","BMW","Toyota"); var_dump($cars); ?>

PHP Constants A constant is an identifier (name) for a simple value. The value cannot be changed during the script. A valid constant name starts with a letter or underscore (no $ sign before the constant name). To create a constant, use the define() function. Parameters: name: Specifies the name of the constant value: Specifies the value of the constant case-insensitive: Specifies whether the constant name should be case-insensitive. Default is false define(name, value, case-insensitive)

PHP Constants The example below creates a constant with a case-sensitive name: The example below creates a constant with a case-insensitive name: <?php define("GREETING", "Welcome to W3Schools.com!"); echo GREETING; ?> <?php define("GREETING", "Welcome to W3Schools.com!", true); echo greeting; ?>

Self Study PHP Variables Scope; Global & Local Scope (https://www.w3schools.com/php/php_variables.asp) PHP The global Keyword (https://www.w3schools.com/php/php_variables.asp) PHP The static Keyword (https://www.w3schools.com/php/php_variables.asp) The PHP print Statement (https://www.w3schools.com/php/php_echo_print.asp) PHP Operators (https://www.w3schools.com/php/php_operators.asp)

References https://www.w3schools.com/ Robin Nixon, Learning PHP, MySQL, JavaScript, and CSS, 2013 Mike McGrath, PHP & My SQL in easy steps, 2012.

The End