intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Web engineering: Lecture 19, 20 - Majid Mumtaz

Chia sẻ: You You | Ngày: | Loại File: PDF | Số trang:19

54
lượt xem
4
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

In lecture 19 and 20, we will learn PHP. What is PHP? PHP originally stood for Personal Home Page. But now PHP stands for PHP Hypertext Preprocessor. PHP is an open soruce server side scripting language. For more information, Inviting you to refer lecture.

Chủ đề:
Lưu

Nội dung Text: Web engineering: Lecture 19, 20 - Majid Mumtaz

  1. Web Engineering Lecture 19-20 MAJID MUMTAZ Department of Computer Science, CIIT Wah 1
  2. PHP • What is PHP:PHP originally stood for Personal Home Page But now • PHP stands for ”PHP: Hypertext Preprocessor” • PHP was originally created by Rasmus Lerdorf in 1995 • PHP is an open soruce server side scripting language 2
  3. PHP • Why we use PHP? We use PHP to create dynamic web pages/sites – It is widely used, – Free and efficient alternative to competitors such as Microsoft ASP, ASP.NET – Competitors of PHP are • ASP/ASP.NET • JSP 3
  4. PHP • What do i need to run PHP pages – Install a web server on your own PC and then install PHP & MYSQL If Your server has activated support for PHP you do not need to do anything. Just create some PHP file, place them in your web directory & the server will automatically parse them for you. 4
  5. PHP • Web Server: Mostly we use the following web servers – WAMP: Window, Apache, MYSQL, PHP – XAMPP: All OS, Apache, MYSQL, PHP, Perl Note: Install the web server start as services & then type localhost in your browser to check whether it is running or not – LAMP: used for Linux Machines users 5
  6. PHP • PHP syntax: derived from many languages- Predominantly the C lanugage, but perl has also had a lot of influance on the syntax. With the latest OO addition more java-like syntax is creeping in as well. Despite incorporating elements of so many languages, PHP syntax remains simple & easy to understand. 6
  7. PHP Recommended • PHP Tags: tags 1 2 3 Standard Tags Short Tags (Not supported Script Tags
  8. PHP Tag Summary 8
  9. PHP • MY First PHP Page: Open notepad and type the following code • Save it with php extension e.g. First.php • How to run this? – Open any web browser and type – http://localhost/first.php – The output will be Welcome to PHP Class 9
  10. PHP • PHP Operators: – Assignment Operator (=) – Arithmatic operator (+, -, *, /, %) – Comparison operator (, >=,
  11. PHP • PHP Assignment operator: Assigns values to variable in php e.g. X+=y; same as x = x + y (Addition) X-=y; same as x = x – y (subtraction) 11
  12. PHP • PHP Logical operators: x&&y (And): true if both x and y are True x||y (OR): true if either or both x & y are true !x (Nor): true if x is not true. • PHP Increment/Decrement operators ++x Pre-increment X++ Post-increment --x Pre-decrement X-- Post-decrement 12
  13. PHP • PHP Conditional statements: We have following conditional statements – If statement – If-else statement – If-elseif-else statement – Switch statement 13
  14. PHP • PHP if statement: Syntax: if(condition){ code will execute if condition is true } Example: $marks = 45; if($marks > 40) { echo ”Congratulation”; echo ”You are pass”; } 14
  15. PHP • Switch statement: To select one ore more blocks of code to be executed switch(n){ case label 1: code to be executed if n=label 1 break; case label 2: code to be executed if n = label 2 break; default: if doesn’t match with any case, it will execute. } 15
  16. PHP • PHP Loops: Loops execute a block of code a specified number of times until the condition remains true. We have following loop statements – For loop (used when we know the no. Of iterations) – While loop (unknown number of itereations) – Do-while loop 16
  17. PHP for Loop • Syntax for (initialization; condition; Increment/decrement) Example: 17
  18. Home work • Create a for loop that displays numbers as: 10 9 8 7 6 5 4 3 2 1. Put the numbers in HTML table cells. • Repeat same task using while loop 18
  19. Questions 19
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
3=>0