Presentation is loading. Please wait.

Presentation is loading. Please wait.

A290 TOOLS IN COMPUTING: PHP

Similar presentations


Presentation on theme: "A290 TOOLS IN COMPUTING: PHP"— Presentation transcript:

1 A290 TOOLS IN COMPUTING: PHP
FALL 2017 FIRST 8 WEEKS WELCOME

2 Introduction Instructor: Olgun Sadik Office: Lindley 401D Office Hour: By appointment (via )

3 Undergraduate Instructor
Jiawei Zhang Office Hours: Mondays 2:30-3:30 Lindley Hall 2nd floor lobby (where the students sleep and study) Individual appointment available via

4 Course Pre-survey Please fill out the course pre-survey from the class website.

5 Course Canvas Site The class website and Canvas are our main resources: Syllabus (the class website) Access to Course Materials (Books 24/7 and the class website) Main Textbook Beginning PHP 5.3 by Matt Doyle Course Schedule (the class website) Assignments/Feedback (Canvas) Announcements (Canvas) Grades (Canvas) In class activities: Pair Programming

6 PHP Personal Home Page PHP Hypertext Preprocessor
Created in 1994 by Rasmus Lerdorf, originally used for tracking visits to his online resume, he named the suite of scripts "Personal Home Page Tools," more frequently referenced as "PHP Tools." Over time, more functionality was desired, and Rasmus rewrote PHP Tools, producing a much larger and richer implementation. This new model was capable of database interaction and more, providing a framework upon which users could develop simple dynamic web applications such as guestbooks. In June of 1995, Rasmus » released the source code for PHP Tools to the public, which allowed developers to use it as they saw fit. This also permitted - and encouraged - users to provide fixes for bugs in the code, and to generally improve upon it. Source:

7 Hypertext “The World Wide Web (WWW) combines computer networking (the Internet) and Hypertext MarkUp Language (HTML) into an easy to use system by which people can access information around the world from a desktop computer.” Hypertext is not a product, it is a concept we use to define ”the medium used to transmit the information in a non-linear fashion via computer by  clicking on a "link"  using a mouse. Hypertext= Hyperlink Source: Source:

8 Preprocessor A program that processes its input data to produce output that is used as input to another program Source: Hanly, J. R., Koffman, E. B., & Friedman, F. L. (1996). Problem Solving and Program Design in C. Addison-Wesley.

9 PHP PHP is a server‐side scripting language for building dynamic, interactive Web sites. PHP code within HTML web pages. A dynamic web page is a page whose contents can change automatically each time the page is viewed. Contrast this with a static Web page, such as a simple HTML file, which looks the same each time it's displayed (at least until the page is next edited). Meanwhile, an interactive Web site is a site that responds to input from its visitors. A Web forum is a good example — users can post new messages to the forum, which are then displayed on the site for all to see. Another simple example is a "contact us" form, where visitors interact with the page by filling out and sending a form, which is then ed to the Webmaster. PHP is a server‐side scripting language, which means that PHP scripts, or programs, usually run on a Web server. (A good example of a client‐side scripting language is JavaScript, which commonly runs within a Web browser.). Furthermore, PHP is an interpreted language — a PHP script is processed by the PHP engine each time it's run.

10 Web Server A host computer for a website(s) that is connected to the Internet. A web server program Ex: Apache, Internet Information Server (IIS) A web site is a collection of web pages which are digital files generally written using HyperText Markup Language (HTML). For a web site to be available to everyone in the world at all times, it need to be stored or “hosted” on a computer that is connected to the internet 24/7/365. Such a computer is known as a Web Server. A web server program is software that runs on the web site hosting Server computer. Its main purpose is serving web pages; which means it waits for requests from web browsers (also known as clients) and responds by sending the required data back. This client-server interaction is the hallmark of how the web works. There are many web server programs available – check list of web servers. The most famous and popular of them all is Apache developed by the Apache Foundation. Web servers – the computer or the program – have a vital role on the Internet. The Server machine hosts (stores) the web site on its hard disk while the server program helps deliver the web pages and their associated files like images, flash movies etc. to clients (browsers). The process of loading a web site/page in a web browser starts with the user either entering the URL in the address bar or clicking on a link. You should know that each web page has a unique address (or URL) on the internet; which means the same page cannot exist in two places. (If a copy does exist in another location, its address would be different from that of the original). Once the appropriate action has been initiated by the user, the browser sends out a request for the web page. Behind the scenes, the domain name (A domain name is simply a human readable form of an I.P. address while a URL stands for Universal Resource Locator and indicates the location of a file on the Internet.) of the requested web page is resolved into an I.P. address (DNS: Domain Name System), which, in English, means, converted to an I.P. address – something that computers understand. The I.P. address points to the location of the web site host. The request is forwarded to Server computer and passed on to the server software. The server software now gets to work and hunts for the requested web page on the hard disk. On finding the file, it sends a response to the browser followed the actual web page file which then starts displaying the page. Source: Doyle, M. (2011). Beginning PHP 5.3. John Wiley & Sons.

11 Process PHP is a server‐side scripting language for building dynamic, interactive Web sites. A visitor requests a Web page by clicking a link, or typing the page's URL into the browser's address bar. The visitor might also send data to the Web server at the same time, either using a form embedded in a Web page The Web server recognizes that the requested URL is a PHP script, and instructs the PHP engine to process and run the script. The script runs, and when it's finished it usually sends an HTML page to the Web browser, which the visitor then sees on their screen. The interesting stuff happens when a PHP script runs. Because PHP is so flexible, a PHP script can carry out any number of interesting tasks, such as: Reading and processing the contents of a Web form sent by the visitor Reading, writing, and creating files on the Web server Working with data in a database stored on the Web server Grabbing and processing data from other Web sites and feeds Generating dynamic graphics, such as charts and manipulated photos And finally, once it's finished processing, it can send a customized HTML Web page back to the visitor. Source: Doyle, M. (2011). Beginning PHP 5.3. John Wiley & Sons.

12 HTML/PHP within each other
<html> <head> <title> PHP introduction </title> </head> <body> <?php echo “Go Hoosiers”; ?> </body> </html> <html> <head> <title> PHP introduction </title> </head> <body> <?php echo “Go <br>”; echo “Hoosiers”; ?> </body> </html>

13 Creating your first script
Go to the following website:

14 Task 1 Search online to learn how to print your name in the result box. <?php echo “Olgun Sadik”; ?>

15 Answer <?php echo “Olgun Sadik”; ?>
The first line tells the PHP engine to expect some PHP code to follow: The next line displays your name PHP's echo() statement takes a string of text — in this case, "Olgun Sadik!" — and sends it as part of the Web page to the browser. The browser then displays the text to the visitor. Notice the semicolon (;) at the end of the line; this tells PHP that you've reached the end of the current statement, and it should look for a new statement (or the end of the PHP code) to follow. The final line of your simple script tells the PHP engine that it's reached the end of the current section of PHP code

16 Task 2 Display your name with the current time For example:
For example: Hello, Olgun. The current time is: 10:20:59 am

17 Answer <?php echo "Hello, Olgun. The current time is: ". date( "g:i:s a" ); ?> The date function takes the current time and formats it as a readable string of text. Date is a predefined function from PHP library. g, i, and s tell PHP to output the current hour, minute, and second, respectively. a tells PHP to display either "am" or ‘pm’ as appropriate. The colons (:) and the space character are not processed by the date() function, so they're displayed as is.

18 Comments To write a single-line comment, start the line with two slashes // This code displays the current time To write multi-line comments, start the comment with a slash followed by an asterisk (/*) and end the comment with an asterisk followed by a slash (*/): /* This code displays the current time in a nice, easy-to-read format. */

19 Most Common Errors in PHP
Error = mistake Parse Error (Syntax Error): The parse error occurs if there is a syntax mistake in the script; the output is Parse error Unclosed quotes Missing or Extra parentheses Unclosed braces Missing semicolon

20 Most Common Errors in PHP
Fatal Error:  Fatal errors are caused when PHP understands what you've written, however what you're asking it to do can't be done. Fatal errors stop the execution of the script. If you are trying to access the undefined functions, then the output is a fatal error.

21 Most Common Errors in PHP
Warning Error: Warning errors will not stop execution of the script. The main reason for warning error is to include a missing file or using the incorrect number of parameters in a function. Notice Error: Notice error is the same as a warning error i.e. in the notice error, execution of the script does not stop. Notice that the error occurs when you try to access the undefined variable, then produce a notice error.

22 Taking care of errors= debugging
Nice articles about debugging

23 Before the next class Install Dreamweaver to your computer from iuware.indiana.edu. You are free to use any text editor that you feel comfortable. I will be using Dreamweaver. Install XAMPP on your laptop/computer. I will look at your pre-survey responses and will make some decisions regarding the syllabus.


Download ppt "A290 TOOLS IN COMPUTING: PHP"

Similar presentations


Ads by Google