tailieunhanh - Lecture Web technology and online services: Lesson 5.1 - PHP

Lecture "Web Technology and online services: Lesson - PHP" provide students with knowledge about: Introduction to PHP; Basic PHP syntax; Some useful PHP functions; How to work with PHP; . Please refer to the detailed content of the lecture! | PHP 1 Content PHP Basics Introduction to PHP a PHP file PHP workings running PHP. Basic PHP syntax variables operators switch while do while and for. Some useful PHP functions How to work with HTML forms cookies files time and date. How to create a basic checker for user-entered data 2 Introduction to PHP Server-side programming tries to avoid the drawbacks Code is embedded in HTML pages and evaluated on the server while the pages are being served. Add dynamically generated content to an existing HTML page. Active Server Pages ASP Microsoft The ASP engine is integrated into the web server so it does not require an additional process. It allows programmers to mix code within HTML pages instead of writing separate programs. Drawback Must be run on a server using Microsoft server software. Java Servlets Sun As CGI scripts they are code that creates documents. These must be compiled as classes which are dynamically loaded by the web server when they are run. Java Server Pages JSP Like ASP another technology that allows developers to embed Java in web pages. 3 Introduction to PHP Developed in 1995 by Rasmus Lerdorf member of the Apache Group originally designed as a tool for tracking visitors at Lerdorf s Web site within 2 years widely used in conjunction with the Apache server free open-source now fully integrated to work with mySQL databases PHP is similar to JavaScript only it s a server-side language PHP code is embedded in HTML using tags when a page request arrives the server recognizes PHP content via the file extension .php or .phtml the server executes the PHP code substitutes output into the HTML page the resulting page is then downloaded to the client user never sees the PHP code only the output in the page The acronym PHP means in a slightly recursive definition PHP Hypertext Preprocessor 4 Basic PHP syntax Hello World A PHP scripting block always starts with . A PHP scripting block can be This is going to be ignored by the PHP interpreter. .