PHP毕业设计英文文献翻译(4)

2019-04-22 07:46

tracking program evolved into a language of its own.

PHP?s primary use certainly isn?t to track resumes anymore; it has grown to be able to do that and just about anything else. To give you a better idea of what PHP can do, here are some of its common uses:

? Feedback forms

? Shopping carts and other types of e-commerce systems

? User registration, access control, and management for online subscription services

? Guest books

? Discussion and message boards

2 If You Are New to Programming

If you?ve never written a computer program before, the whole idea may be quite intimidating. Most programmers will probably tell you (if they aren?t embarrassed to admit it) that they were intimidated when they began. However, the programming process isn?t all that difficult and, contrary to popular belief, you don?t have to have an extremely high IQ to be good at it.

When you write a program, your main goal is to translate your idea into a language that the computer can understand. For example, if you were teaching a person how to cook hamburgers, you would first describe the process of forming the ground beef into patties. Then, you would tell the person how to put the burgers on the grill, how long to leave them there, and finally how to remove them.

Of course, just because you can describe the process of making hamburgers doesn?t mean PHP is going to be cooking anything for you anytime soon. The point is, if you can describe a process like I just described making hamburgers, you can write a program.

Writing a PHP program is simply the process of describing to PHP how to do something. By the time you?ve finished reading this article, you will understand

15

all the concepts behind writing a PHP program. Those concepts are like the words and sentences used to describe hamburgers. The more you read this article, the more “words” you will understand, and the better you will be able to “describe” your task to PHP. Thus, you will learn to write PHP programs to suit whatever need or idea you have, and soon it won?t be any more intimidating than telling someone how to cook hamburgers.

Some programming problems might be very complex when examined as a whole. For example, creating a shopping cart is definitely not a simple task. However, a shopping cart can be broken into a few smaller tasks. Those tasks might include adding and removing items, which are both tasks that can break into even smaller tasks. You will find that any task, no matter how complex, can be broken into smaller ones until each task is simple enough that breaking it down further is unnecessary. This process is explained in more detail when you begin creating programs with more complexity

3

Writing a Basic PHP Program

Before we get into an actual program, let?s take a look at the steps we?ll take to create one. The steps aren?t complicated; in fact, they?re basically the same as the steps you use when creating an HTML page and publishing it to your server.

Unlike creating an HTML page, creating a PHP program requires that you actually work with the source code of the file as opposed to a “what you see is what you get” (WYSIWYG) approach. If you?re used to using a WYSIWYG program (such as Microsoft FrontPage, Macromedia Dream-Weaver, or Microsoft Word), it may take you some time to get used to looking at the source code.

The good news is there?s no reason that you can?t continue to use a WYSIWYG editor to create an HTML design for your program. However, you may be disappointed to find that many WYSIWYG editors mangle or even delete vital PHP code from your files. For this reason, it is important to find out how your particular editor handles PHP code. If you want to test your WYSIWYG to

16

see how it handles PHP code, create a new file, naming it with a .php extension. Then, switch to your editor?s source view or open the file in a separate program, such as Notepad and enter the program shown in the first example later in the chapter, making sure not to make any mistakes.

When you?re finished, save the file and switch back to the WYSIWYG editor. If you see your PHP code, work around it and type a few lines of text. If you want, add some common elements that you include in your Web pages, such as tables and images. Save the file again and close all the open editors.

Now, open the file in Notepad and look at the PHP code. Look for any changes, including changes in the way the code is formatted, special characters that have been converted into codes (such as < to <), and code that has been completely removed.

You will probably find that the PHP code has been changed in some way. Because PHP is sensitive to some of the changes a WYSIWYG editor might make, it?s almost impossible to use a WYSIWYG editor once you?ve started adding PHP code. The PHP community won?t tell you that using a WYSIWYG editor is a sign of weakness; doing so can speed things up a lot sometimes.

For now, try using a plain-text editor when you?re reading and experimenting with the examples in this article. When you?re comfortable with that, feel free to try it with whatever editor you want. By that time, you?ll be able to recognize code that the editor has mangled, and you?ll have an easier time finding what works best for you.

Regardless of how your current editor handles PHP code, if you are using a WYSIWYG editor, I suggest that you use an editor such as Notepad or one of the many free syntax-highlighting editors out there. Using one of these programs will ensure that your code stays just as you typed it (WYSIWYG editors tend to reformat things as they see fit, which isn?t desirable when coding PHP). Even if your editor passed the test, if it?s not a strictly text based (not WYSIWYG) editor, you might find yourself running into problems later.

Here is the process you might use in creating and viewing an HTML file:

17

1. Create your HTML file (add text, tables, images, or sounds). 2. Save your HTML file as filename.html.

3. Use an FTP program to upload your file to the Web server.

4. Point your browser to the address of the file on your Web server (for example, http://www.example.com/filename.html).

The process you would use to create a PHP program is much the same: 1. Create your HTML file (containing text, tables, images, or sounds) and insert PHP code where desired. 2. Save your PHP file as filename.php.

3. Use an FTP program to upload your file to the Web server.

4. Point your browser to the address of the file on your Web server (such as http://www.example.com/filename.php).

The process of creating a PHP program isn?t much different from the process you follow to create a regular HTML page.

Now that you?ve seen the overall process, let?s take a look at our first PHP program. After reading the following example, you?ll learn what separates it from a normal HTML file, how to upload it to your Web server, and what the page should look like viewed in your browser.

PHP

PHP

/* Display a text message */

echo “Hello, world! This is my first PHP program.”; ?>

This file looks a lot like a regular HTML file. Notice that the file has HTML

18

tags typical of those you would find in any HTML file. In fact, if you disregard everything between the tags, you might as well rename this file with an .html extension.

However, this file does contain PHP code, so it must be named with a .php extension. The PHP code lies between the PHP tags () as shown in Figure 1.1. The command between the PHP tags is echo (PHP?s word for “add the following text to the page”) followed by the text to display. The output, which will be shown soon, looks just as if the text after echo had been in an HTML file itself and no PHP code ever existed.

Figure 1.1: This diagram shows the different parts of a basic PHP program. Before we look at the output, let?s upload this file to a Web server and run it. Follow the process outlined previously to write the program, save it as a PHP file (with a .php extension), and upload it to your Web server.

Once your program is uploaded to your Web server, type its address into your browser. You should get a page back that looks very similar to the screenshot in Figure 1.2.

19


PHP毕业设计英文文献翻译(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:趵突泉教学反思

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: