If you are using the Xampp suggested by Rob on the last page, then you may need to place your file in C:/xampp/htdocs/xampp in order for it to be viewed correctly if you are not working on a server but simply learning from own computer.
第一个 PHP 页面
在 web 服务器根目录(
该程序非常的简单,它仅仅只是利用了 PHP 的 echo() 语句显示了 Hello World。用户一定不会满足与此。请注意该文件无需被执行或以任何方式指定。服务器会找到该文件并提供给 PHP 进行解释,因为使用了“.php”的扩展名,服务器已被配置成自动传递有着“.php”扩展名的文件给 PHP。一个普通的 HTML 文件,加上了几个特别的标签,就可以做很多非常有趣的事情! 如果试过了这个例子,但是没有得到任何输出,或者浏览器弹出了下载框,或者浏览器以文本方式显示了源文件,可能的原因是服务器还没有支持 PHP,或者没有正确配置。需要请服务器的管理员根据本手册“安装”一章的内容使得服务器支持 PHP。如果本地开发,请阅读手册有关安装的章节以确保所有的设置都正确。还要确认通过浏览器访问的 URL 确实指向了服务器上的这个文件。如果只是从本地文件系统调用这个文件,它不会被 PHP 解析。如果问题仍然存在,请通过 PHP 在线支持中的各种方式获取帮助。 以上例子的目的是为了显示 PHP 特殊标识符的格式。在这个例子中,用 <?php 来表示 PHP 标识符的起始,然后放入 PHP 语句并通过加上一个终止标识符 ?> 来退出 PHP 模式。可以根据自己的需要在 HTML 文件中像这样开启或关闭 PHP 模式。请参阅手册中“PHP 基本语法”以获取更多信息。
现在已经成功建立了一个简单的 PHP 脚本。还可以建立一个最著名的 PHP 脚本。调用函数 phpinfo(),将会看到很多有关自己系统有用的信息,以及预定义变量、已经加载的 PHP 模块和配置信息。请花一些时间来查看这些重要的信息。
R0pehijak
26-Jun-2007 11:06
If you are using the Xampp suggested by Rob on the last page, then you may need to place your file in C:/xampp/htdocs/xampp in order for it to be viewed correctly if you are not working on a server but simply learning from own computer.
jt at fuw dot edu dot pl
19-May-2007 11:48
Well, but PHP file ownership is important when server has safe_mode enabled - HTTP server checks it, uses it to set UID of process which executes it, or may even refuse to execute such a file - e.g. if one user is owner of main PHP file, and the main file includes another, owned by other user, this is considered to be security violation (quite reasonably).
Admin at e-information4you dot com
07-May-2007 03:15
Your host may not use a folder called 'document_root'. I use gator host and they use 'public_html'. Basically I would advise ignoring this, just upload the php file to where ever you want.
30-Apr-2007 11:02
In the note submitted by HobbyTech on 08-Aug-2006 it is not Internet Explorer but Windows Explorer that you want. In other words, run Start | My Computer instead of Internet Explorer and then carry on as per his remaining instructions.
tinscurv at Hotmail dot com
12-Apr-2007 05:29
I noticed that it mentioned to add a "double quote" i.e "hello.php", when saving a php file when the drop down menu says txt. It is not necessary. You can type the whole name without quotes when the drown down menu is either txt or all. UNLESS, maybe for older windows? But for newer windows, it is not necessary. It works without a double quote. Anyway, if double quote is mentioned in the manual, then window versions needs to be stated.
Geoff
18-Mar-2007 10:56
People with file extension woes on Win32 really just need a better text editor. Notepad2 is easy, very like notepad and supports syntax highlighting; quite a neat little thing:
Stewart
05-Jan-2007 10:55
No need to go through these contortions each time to make sure the file is properly saved with the .php extension. Just register .php as a file type in Windows, and then saving as hello.php without the quotes will work fine.
HobbyTech
09-Aug-2006 05:12
On Windows, if file extensions can be hidden, you may not SEE that you have accidently saved a file as 'Text Documents' (and that the browser has added '.txt' to the end of your 'page.html', resulting in 'page.html.txt'.) You still see only 'page.html' even though it's really 'page.html.txt'. Also, if you try to rename it, it won't work because it's not overwriting the '.txt' part and not changing the filetype.
c300501 at yahoo dot com
07-Jun-2006 01:26
document_root variable is located in your web server configuration file
onebadscrivener at gmail dot com
18-Jan-2005 01:25
OS X users editing in TextEdit will need to make sure their TextEdit preferences are set to allow plain text files. Under the TextEdit pull-down menu, choose PREFERENCES, then under NEW DOCUMENT ATTRIBUTES in the window that pops up, click PLAIN TEXT.
Curtis
10-Aug-2004 09:47
Expansion on saving w/ notepad/wordpad: (tested on XP; but should work on 2000,NT, and 98)
ryan420 at earthling dot net
03-Feb-2003 10:18
Note on permissions of php files: You don't have to use 'chmod 0755' under UNIX or Linux; the permissions need not be set to executable. Again, this is more like a html file than a cgi script. The only mandatory requirement is that the web server process has read access to the php file(s). With many Linux systems, it is popular for Apache to run under the 'apache' account. Given that HTML and other web files, like php, are often owned by user 'root' and group 'web' (or another similar group name), acceptable permissions might be those achieved with 'chmod 664' or 'chmod 644'. The web server process, running under the 'apache' account, will inherit read only permissions. The 'apache' account is not root and is not a member of the 'web' group, so the "other" portion of the permissions (the last "4") applies.
| |||