php中的文件路径

php中的文件路径,php,Php,我从2012年开始学习educator的php课程。没有人回答任何问题。我将包含练习的文件夹放在C:\wamp\www\educator php advance中 问题是,这些图像不会出现在任何练习页面上。我认为问题出在配置文件中。我对php不太了解,所以我不明白教授在这里做了什么,因为他没有解释这个文件 // Get absolute path to 'this' config.php file and replace // any backslashes in its path with

我从2012年开始学习educator的php课程。没有人回答任何问题。我将包含练习的文件夹放在C:\wamp\www\educator php advance中

问题是,这些图像不会出现在任何练习页面上。我认为问题出在配置文件中。我对php不太了解,所以我不明白教授在这里做了什么,因为他没有解释这个文件

// Get absolute path to 'this' config.php file and replace 
// any backslashes in its path with forward-slashes if needed
$configFilePath = str_replace('\\', '/', __FILE__);

// Get URI of this config.php file relative to the 
// webserver's document root by removing the 
// $_SERVER['DOCUMENT_ROOT'] path from the path to config.php
$configFileURI = str_replace($_SERVER['DOCUMENT_ROOT'], 
                                '', $configFilePath); 

/**
 * Define the root URI for this version of the web app based on the URI of this config.php file
 */
define('ROOT_URI', str_replace('includes/config.php', '', $configFileURI));

/**
 * Image directory URI constant
 */
define('IMAGE_DIR', ROOT_URI . 'images/');  
当我在浏览器中查看图像时,这是url:

http://localhost/educator-php-advance/web_app/version-5.0/educator-php-advance/web_app/version-5.0/images/1001.jpg
因此,如果我使用以下命令更改图像路径:

    define('IMAGE_DIR', '/educator-php-advance/web_app/version-4.0/images/');
我能看到图像。
有人能告诉我如何更改常数以便我能看到图像吗?

我不确定我是否理解您的问题?问题是什么?如果图像显示为
define('IMAGE_DIR','/educator-php-ad…
然后使用它?我必须为每节新课更改该常数,在某些课中,我必须移动图像文件夹并再次更改路径。你能尝试回显
图像_DIR
它的输出吗?…我不确定我是否得到了问题?是的,你必须更新
图像_DIR
constat使其在常量错误的文件中工作?如果我回显IMAGE_DIR,则输出为1。