Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 19 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
19
Dung lượng
189,5 KB
Nội dung
Introduction to PHP Session Objectives Discuss the history of PHP Identify the need for PHP List the PHP tools Write a simple PHP script Use PHP to generate HTTP headers PHP / Session / Slide of 19 History of PHP - I An advance product of PHP/FI PHP/FI stands for Personal Home Page/Forms Interpreter Rasmus Lerdorf created PHP/FI in the year 1995 PHP/FI got advanced to PHP/FI 2.0 in the year 1997 Andi Gutmans and Zeev Surakshi advanced PHP/FI 2.0 to PHP 3.0 in the year 1997 This was the first version of recent PHP PHP / Session / Slide of 19 History of PHP - II PHP 3.0 provides a concrete infrastructure for different databases, protocols, and APIs to the end users along with the support for object oriented syntax PHP 3.0 got advanced to PHP 4.0 in the year 1998 PHP 4.0 includes supportive features for more Web servers, HTTP sessions, output buffering, and security while handling user inputs This is the latest version of PHP PHP / Session / Slide of 19 Need for PHP Uses in server-side scripting It is platform independent Advantages of using PHP are: Easy to learn, use, and implement Free for access Executes on any platform Executes scripts from the command line and develops client-side GUI applications that can operate on any platform Uses of PHP are application control, database access, file access, and graphics PHP / Session / Slide of 19 PHP tools and setup - I Uses for developing and designing a web pages Contains all the supporting features for the fast developments of the web sites These tools are basically the programming text editors The tools are: PHPEd – Helps a developer in developing applications by supporting PHP scripts and its syntaxes It is freely available to the users It is available with version 3.3 PHPDebugger DBG – Helps the PHP scripts to get executed in steps It helps to trace out the errors in scripts This tool is freely available to the users Its current version is 2.11.23 PHP / Session / Slide of 19 PHP tools and setup - II ionCube Standalone PHP Encoder – Helps in speeding up the execution of the scripts It is freely available Its updated version is 3.1 The main functionality of this tool is that it does not allow the document to get corrupted Codelock – Works with the PHP scripts It is freely available with 2.0 versions PHing – Performs various file system operations while processing a file The working of this tool depends on the platform where the PHP is working It is freely available for users Its updated version is 1.0rc2 PHP / Session / Slide of 19 PHP tools and setup - III NuSphere PHPEd – Uses 3.1.2 version It is freely available for the users It is an Integrated Development Environment that includes all functionalities for developing dynamic web sites xored:WebStudio – Uses the updated version of the tool Its latest version is 0.2.2 It works with the free availability for the users This tool is built on eclipse platform An eclipse platform is a tool platform for open source IDE PHPmole – Uses GNOME platform for working with PHP Its latest version is 1.3 that is freely available to the users This tool is a combination of Dreamweaver software with Microsoft Visual studio software PHP / Session / Slide of 19 PHP tools and setup - IV Simplewire PHP SMS Software Development kit – Works with the wireless messaging network to send SMS to mobile phones It is freely available in 2.3.0 version Quanta Plus Web Development Environment – Uses 2.0 version of tool It is freely available to the users It is a web development tool K PHP Develop – Supports MySQL as a database server It is freely available with 0.1.6 version of the software It has different modules such as server, server setup, clients and plugins Gedit – Uses for writing PHP scripts It gets installed by default while installing Linux It is just like a notepad of windows PHP / Session / Slide of 19 Writing a Simple PHP script Starts with tag Scripts are embedded in the BODY tag of the HTML file Saves with an extension, php under the /var/www/html directory For example, display a simple text in the browser PHP / Session / Slide 10 of 19 Example for Simple PHP Script Enter the PHP codes in gedit text editor PHP / Session / Slide 11 of 19 Output of the PHP Script Enter http://localhost/stringdisp.php in the address bar The output appears, as shown in the figure PHP / Session / Slide 12 of 19 Using PHP to generate HTTP headers HTTP is HyperText Transfer Protocol It is a network transmission protocol Uses with the help of TCP/IP protocol Divides into three parts namely, request and response line, HTTP header, and the body of the protocol PHP / Session / Slide 13 of 19 About HTTP header Sends information to the client or the server about the application that will be displayed on the browser Informs about the application is on request line or on the response line Divides into three different categories like general, entity, and request/response Generates the HTTP headers using the header() function PHP / Session / Slide 14 of 19 Using header() function Passes the HTTP commands to the server through the HTTP protocols using the header() function Syntax for using the simple header() function is: void header (‘string string’) Where, string - Includes authenticating or validating strings for the server The whole string is enclosed in the single quotes PHP / Session / Slide 15 of 19 Example using header() function For example, use an authenticating string in the header() function PHP / Session / Slide 16 of 19 Using options of header() function The syntax for using header() http_response_code option is: function with void header (http_response_code) Where, http_response_code - Shows the response of the web server on any request It shows the response like status or the location of the client PHP / Session / Slide 17 of 19 Example using the option For example, show the location of the client PHP / Session / Slide 18 of 19 Summary PHP is a general purpose scripting language used for developing dynamic web pages and embedded in HTML tags PHP is developed from C-modules, therefore the scripts are also executed from the command line to make client-side GUI applications PHP is also used for generating files in various formats like PDF and HTML formats PHP script starts with tag These scripts are embedded in the HTML tags PHP uses tools such as text editors for developing and designing web pages Gedit is the most popular text editor used for programming on Linux platform PHP / Session / Slide 19 of 19 [...]... for Simple PHP Script Enter the PHP codes in gedit text editor < ?php echo “Hello Everybody”; ?> PHP / Session 1 / Slide 11 of 19 Output of the PHP Script Enter http://localhost/stringdisp .php in the address bar The output appears, as shown in the figure PHP / Session 1 / Slide 12 of 19 Using PHP to generate HTTP headers HTTP is HyperText Transfer Protocol It... function PHP / Session 1 / Slide 14 of 19 Using header() function Passes the HTTP commands to the server through the HTTP protocols using the header() function Syntax for using the simple header() function is: void header (‘string string’) Where, string - Includes authenticating or validating strings for the server The whole string is enclosed in the single quotes PHP / Session 1 / Slide 15 of 19 Example... < ?php header(‘WWW-Authenticate: Negotiate’); ?> PHP / Session 1 / Slide 16 of 19 Using options of header() function The syntax for using header() http_response_code option is: function with void header (http_response_code) Where, http_response_code - Shows the response of the web server on any request It shows the response like status or the location of the client PHP / Session 1 / Slide 17 of 19 ... protocol Uses with the help of TCP/IP protocol Divides into three parts namely, request and response line, HTTP header, and the body of the protocol PHP / Session 1 / Slide 13 of 19 About HTTP header Sends information to the client or the server about the application that will be displayed on the browser Informs about the application is on request line or on the response line Divides into three... generating files in various formats like PDF and HTML formats PHP script starts with < ?php tag and ends up only with the ?> tag These scripts are embedded in the HTML tags PHP uses tools such as text editors for developing and designing web pages Gedit is the most popular text editor used for programming on Linux platform PHP / Session 1 / Slide 19 of 19 ... the location of the client < ?php header(“Location: http://www.msn.com”); exit; ?> PHP / Session 1 / Slide 18 of 19 Summary PHP is a general purpose scripting language used for developing dynamic web pages and embedded in HTML tags PHP is developed from C-modules, therefore the scripts are also executed from the command line to make client-side GUI applications PHP is also used for generating