本文目录一览:
如何执行PHP脚本
php文件如何打开:
确保电脑上安装有php的运行环境如:wampserver, phpstudy等等
安装好后,把php文件复制进对应的目录(一般是www目录下);
在浏览器上输入localhost/加你的php文件路径(localhost在这里就代表www目录,你只需要把后面的路径补齐即可),按下enter,php脚本将被自动解析运行
PHP如何 运行其他目录的PHP文件
php去运行其他目录的php文件只要直接包含那个文件就运行了,方式主要有下面几种:
require 'xxx.php';
require_once 'xxx.php';
include 'xxx.php';
include_once 'xxx.php';
扩展:
如果是用命令行去运行php文件,可以使用在php安装目录下的bin目录里面的php.exe命令去运行,用这种方法运行php的一般是用作定时计划任务。
win下如何配置apache+php使user目录能运行php脚本
我的apache+php 安装在C:\Program Files\LocalHost目录下,主目录doc_root也在这个目录下面,我已经配置好在主根目录,能运行各种php脚本没有问题。但是,现在我想配置用户目录,使得用户目录也能执行php脚本。我的配置方法是: 文件:php.ini user_dir =D:\Downloads\User\Userdir (并在userdir下建立sisy目录,作为单个的用户目录,并在下面建立了两个文件:index.php、test.htm) 文件:httpd.conf 因为主目录已经配置成功,运行正常,此处略。 文件:httpd-userdir.conf UserDir "D:/Downloads/User/Userdir" Directory "D:/Downloads/User/Userdir" Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all /Directory 但是,我打开 正常,打开 失败,提示找不到网页。出错时日志如下: error.log [Tue Aug 25 18:01:28 2009] [notice] Child 740: Exit event signaled. Child process is ending. [Tue Aug 25 18:01:29 2009] [notice] Child 740: Released the start mutex [Tue Aug 25 18:01:30 2009] [notice] Child 740: All worker threads have exited. [Tue Aug 25 18:01:30 2009] [notice] Child 740: Child process is exiting [Tue Aug 25 18:01:30 2009] [notice] Parent: Child process exited successfully. [Tue Aug 25 18:01:35 2009] [notice] Apache/2.2.11 (Win32) configured -- resuming normal operations [Tue Aug 25 18:01:35 2009] [notice] Server built: Dec 10 2008 00:10:06 [Tue Aug 25 18:01:35 2009] [notice] Parent: Created child process 420 [Tue Aug 25 18:01:35 2009] [notice] Child 420: Child process is running [Tue Aug 25 18:01:35 2009] [notice] Child 420: Acquired the start mutex. [Tue Aug 25 18:01:35 2009] [notice] Child 420: Starting 64 worker threads. [Tue Aug 25 18:01:35 2009] [notice] Child 420: Starting thread to listen on port 86. access.log 127.0.0.1 - - [25/Aug/2009:18:01:38 +0800] "GET /~sisy/test.htm HTTP/1.1" 200 17 127.0.0.1 - - [25/Aug/2009:18:01:45 +0800] "GET /~sisy/ HTTP/1.1" 404 25 127.0.0.1 - - [25/Aug/2009:18:02:04 +0800] "GET /~sisy/ HTTP/1.1" 404 25 127.0.0.1 - - [25/Aug/2009:18:19:30 +0800] "GET /~sisy/ HTTP/1.1" 404 25 127.0.0.1 - - [25/Aug/2009:18:21:43 +0800] "GET /~sisy/ HTTP/1.1" 404 25 不知道如何应该如何配置.conf文件和php.ini,才能使得可以在用户目录中运行php脚本? [ 本帖最后由 yt717 于 2009-8-25 18:28 编辑 ] 本篇文章来源于PHP论坛 文章地址: -php脚本运行目录下