tailieunhanh - Lecture Software engineering: Lecture A-D2 - Ivan Marsic

Lecture provides knowledge of PHP scripting language. This chapter presents the following content: Syntax, variables, types; operators, expressions, math functions; string operations and functions; PHP processor output; control statements; PHP in HTML; arrays; user-defined functions; pattern matching; form handling; MySQL database access from PHP; cookies and session tracking. | Ivan Marsic Rutgers University LECTURE: PHP Scripting Language | | | Topics Syntax, Variables, Types Operators, Expressions, Math Functions String Operations and Functions PHP Processor Output Control Statements PHP in HTML Arrays User-Defined Functions Pattern Matching Form Handling MySQL Database Access from PHP Cookies and Session Tracking What is PHP? Originally an acronym for Personal Home Page that later became PHP: Hypertext Preprocessor PHP is a server-side scripting language whose scripts are embedded in HTML documents Alternatives: JSP, Ruby on Rails, Python, , etc. The web server contains software that allows it to run those programs and send back their output (HTML documents) as responses to client requests Server-side scripting languages are used for HTML form handling User authentication File processing . | Ivan Marsic Rutgers University LECTURE: PHP Scripting Language | | | Topics Syntax, Variables, Types Operators, Expressions, Math Functions String Operations and Functions PHP Processor Output Control Statements PHP in HTML Arrays User-Defined Functions Pattern Matching Form Handling MySQL Database Access from PHP Cookies and Session Tracking What is PHP? Originally an acronym for Personal Home Page that later became PHP: Hypertext Preprocessor PHP is a server-side scripting language whose scripts are embedded in HTML documents Alternatives: JSP, Ruby on Rails, Python, , etc. The web server contains software that allows it to run those programs and send back their output (HTML documents) as responses to client requests Server-side scripting languages are used for HTML form handling User authentication File processing Database access Other services, ., email, Lifecycle of a PHP Web Request Browser requests a .html file (static content): server just sends that file Browser requests a .php file (dynamic content): server reads it, runs any script code inside it, then sends result across the network PHP script outputs an HTML document that is sent back PHP file itself is never sent to the client/browser; only its output is Web Browser User’s Computer Server Computer Web Server Hello . Hello world! GET PHP Script Execute script HTML Output Operating Modes The PHP processor has two modes: copy (HTML), and interpret (PHP) PHP syntax is similar to that of JavaScript PHP is dynamically typed PHP is purely interpreted General Syntactic Characteristics PHP code can be specified in an HTML document internally or externally: Internally: