Lesson 1 - Intro to Web Devt. PDF
Document Details
Uploaded by UnrivaledCalcium
University of Makati
Prof. ARIEL DOMINGO
Tags
Summary
This document is an introductory lesson on web development using PHP. It covers fundamental concepts about PHP, including its purpose, features, and installation instructions.
Full Transcript
COMPUTER PROGRAMMING 3 WEB APPLICATION USING PHP Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP PHP Fundamentals WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started wit...
COMPUTER PROGRAMMING 3 WEB APPLICATION USING PHP Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP PHP Fundamentals WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP Ø What is PHP? ü PHP is an open-source, interpreted, and object-oriented scripting language that can be executed at the server-side. ü PHP is well suited for web development. Therefore, it is used to develop web applications (an application that executes on the server and generates the dynamic page.). ü PHP was created by Rasmus Lerdorf in 1994 but appeared in the market in 1995. ü PHP 7.4.0 is the latest version of PHP, which was released on 28 November. WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP Ø Some important points need to be noticed about PHP are as followed: ü PHP stands for PHP: Hypertext Preprocessor. ü PHP is an interpreted language, i.e., there is no need for compilation. ü PHP is faster than other scripting languages, for example, ASP and JSP. ü PHP is a server-side scripting language, which is used to manage the dynamic content of the website. ü PHP can be embedded into HTML. ü PHP is an object-oriented language. ü PHP is an open-source scripting language. ü PHP is simple and easy to learn language. WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP Ø Why use PHP PHP is a server-side scripting language, which is used to design the dynamic web applications with MySQL database. ü It handles dynamic content, database as well as session tracking for the website. ü You can create sessions in PHP. ü It can access cookies variable and also set cookies. ü It helps to encrypt the data and apply validation. ü PHP supports several protocols such as HTTP, POP3, SNMP, LDAP, IMAP, and many more. ü Using PHP language, you can control the user to access some pages of your website. ü As PHP is easy to install and set up, this is the main reason why PHP is the best language to learn. ü PHP can handle the forms, such as - collect the data from users using forms, save it into the database, and return useful information to the user. For example - Registration form. WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP Ø Features ü PHP is very popular language because of its simplicity and open source. ü There are some important features of PHP: WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP Ø Features ü Performance: PHP script is executed much faster than those scripts ü Open Source: which are written in other languages such as JSP and PHP source code and software are freely available ASP. PHP uses its own memory, so the server on the web. You can develop all the versions of PHP workload and loading time is automatically reduced, according to your requirement without paying any which results in faster processing speed and better cost. All its components are free to download and performance. use. ü Embedded: ü Familiarity with syntax: PHP code can be easily embedded PHP has easily within HTML tags and script. understandable syntax. Programmers are comfortable coding with it. WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP Ø Features ü Control: Different programming languages require long ü Platform Independent: script or code, whereas PHP can do the same PHP is available for WINDOWS, MAC, LINUX & UNIX work in a few lines of code. It has maximum operating system. A PHP application developed in one control over the websites like you can make OS can be easily executed in other OS also. changes easily whenever you want. ü Database Support: ü Loosely Typed Language: PHP supports all the leading databases PHP allows us to use a variable without declaring its datatype. It will be taken automatically at the time of such as MySQL, SQLite, ODBC, etc. execution based on the type of data it contains on its value. WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP Ø Features ü Security: PHP is a secure language to develop the ü Error Reporting: website. It consists of multiple layers of PHP has predefined error security to prevent threads and malicious reporting constants to generate attacks. an error notice or warning at runtime. E.g., E_ERROR, E_WARNING, E_STRICT, ü A Helpful PHP Community: E_PARSE. It has a large community of developers who regularly updates ü Web servers Support: documentation, tutorials, online help, PHP is compatible with almost all local servers used today like and FAQs. Apache, Netscape, Microsoft IIS, etc. Learning PHP from the communities is one of the significant benefits. WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP Ø PHP is a server-side language: ü When you open a website on your web browser, for example, https://www.phptutorial.net ü The web browser sends an HTTP request to a web server where phptutorial.net locates. The web server receives the request and responds with an HTML document. ü In this example, the web browser is a client while the web server is the server. The client requests for a page, and the server serves the request. ü PHP runs on the web server, processes the request, and returns the HTML document. WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP Ø Web Development ü PHP is widely used in web development nowadays. PHP can develop dynamic websites easily. ü But you must have the basic the knowledge of following technologies for web development as well. § HTML § CSS § JavaScript § Ajax § XML and JSON § jQuery WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP Ø Web Development Prerequisite ü Before learning PHP, you must have the basic knowledge of HTML, CSS, and JavaScript. So, learn these technologies for better implementation of PHP. § HTML - HTML is used to design static webpage. § CSS - CSS helps to make the webpage content more effective and attractive. § JavaScript - JavaScript is used to design an interactive website. WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP Ø PHP is a general-purpose language: ü When it comes to the purpose of the programming languages, there are two main types: domain-specific and general- purpose languages. ü The domain-specific languages are used within specific application domains. For example, SQL is a domain-specific language. It’s used mainly for querying data from relational databases. And SQL cannot be used for other purposes. ü On the other hand, PHP is a general-purpose language because PHP can develop various applications. WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP Ø PHP is a cross-platform language ü PHP can run on all major operating systems, including Linux, Windows, and MacOS. ü You can use PHP with all leading web servers such as Nginx, OpenBSD, and Apache. Some cloud environments also support PHP like Microsoft Azure and Amazon AWS. ü PHP is quite flexible. It’s not just limited to processing HTML. PHP has built-in support for generating PDF, GIF, JPEG, and PNG images. ü One notable feature of PHP is that it supports many databases, including MySQL, PostgreSQL, MS SQL, db2, Oracle Database, and MongoDB. WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP What can PHP do Ø PHP has two main applications: ü Server-side scripting – PHP is well- suited for developing dynamic websites and web applications. ü Command-line scripting – like Python and Perl, you can run PHP script from the command line to perform administrative tasks like sending emails and generating PDF files. WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP How PHP Works Ø The following illustrates how PHP works: ü First, the web browser sends an HTTP request to the web server, e.g., index.php. ü Second, the PHP preprocessor that locates on the web server processes PHP code to generate the HTML document. ü Third, the web server sends the HTML document back to the web browser. WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP Advantages of PHP Ø Since PHP is designed for the web in the first place, it brings many advantages to web development: ü Simple – PHP is quite easy to learn and get started. ü Fast – PHP websites typically run very fast. ü Stable – PHP is stable since it has been in existence for a long time. ü Open-source and free – PHP is open source and free. It means that you don’t have to pay a license fee to use PHP to develop software products. ü Community support – PHP has an active online community that helps you whenever you face an issue. WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP Install PHP § Installing PHP on your computer allows you to safely develop and test a web application without affecting the live system. § To work with PHP locally, you need to have the following software: ü PHP ü A web server that supports PHP. We’ll use the Apache webserver. ü A database server. We’ll use the MySQL database server. § Typically, you won’t install all this software separately because connecting them is tricky and not intended for beginners. § Therefore, it’s easier to find an all-in-one software package that includes PHP, a web server, and a database server. One of the most popular PHP development environments is XAMPP. § XAMPP is an easy install Apache distribution that contains PHP, MariaDB, and Apache webserver. XAMPP supports Windows, Linux, and macOS. WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP Install PHP § To install PHP, we will suggest you to install AMP (Apache, MySQL, PHP) software stack. It is available for all operating systems. There are many AMP options available in the market that are given below: ü WAMP for Windows ü LAMP for Linux ü MAMP for Mac ü SAMP for Solaris ü FAMP for FreeBSD ü XAMPP (Cross, Apache, MySQL, PHP, Perl) for Cross Platform: It includes some other components too such as FileZilla, OpenSSL, Webalizer, Mercury Mail, etc. § If you are on Windows and don't want Perl and other features of XAMPP, you should go for WAMP. In a similar way, you may use LAMP for Linux and MAMP for Macintosh. WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO INTRODUCTION TO WEB DEVELOPMENT Getting Started with PHP XAMPP CONTROL PANEL Completing the XAMPP setup The XAMPP Control Panel lists installed services. To start a service, you click the corresponding Start button: The following shows the Apache web server and MySQL are up and running. The Apache web server listens on the ports 80 and 443 while the MySQL listens on port 3306: WEB APPLICATION USING PHP| Prof. ARIEL DOMINGO COMPROG2WEB APPLICATION | COMPUTER USING PHP|2 (Elective) PROGRAMMING Prof. ARIEL DOMINGO | Prof. ARIEL DOMINGO COMPROG2WEB APPLICATION | COMPUTER USING PHP|2 (Elective) PROGRAMMING Prof. ARIEL DOMINGO | Prof. ARIEL DOMINGO