[英]File includes from Linux to Windows
I have faced the problem. 我已经遇到了问题。 The script is written in Linux environment and i am using windows. 该脚本是在Linux环境中编写的,我正在使用Windows。 When i have downloaded the entire script, the includes has stopped working. 当我下载了整个脚本后,包括已停止工作。 Example: 例:
<?PHP
include("/var/www/keytarget.adnet.lt/data/core/php/class/CurrentVersionNumber/main.php");
if (VERSION_NUMBER) {
include("/var/www/keytarget.adnet.lt/data/version/" . VERSION_NUMBER . "/php/class/KeytargetLocalCacheSingleton.php");
include("/var/www/keytarget.adnet.lt/data/version/" . VERSION_NUMBER . "/php/class/KeytargetPdo.php");
include("/var/www/keytarget.adnet.lt/data/version/" . VERSION_NUMBER . "/php/class/Receiver.php");
$currentKeywordReceiver = new Receiver("HTML");
}
?>
Any ideas of how can i replace include URLs so that it would be windows URL ? 关于如何替换URL的任何想法都将成为Windows URL? Like C:\\wamp\\www\\data or something similar ? 像C:\\ wamp \\ www \\ data或类似的东西?
Download some text editor and replace all occurrences. 下载一些文本编辑器并替换所有出现的内容。
Or use a php script that will replace it. 或使用将替换它的php脚本。 And it's a good practice to don't use the full path and use $_SERVER['DOCUMENT_ROOT'] instead. 最好不要使用完整路径,而应使用$ _SERVER ['DOCUMENT_ROOT']。
The php script should like something like this: php脚本应如下所示:
<?php
$toreplace = "/var/www/"; // the old path to root
$replace = "C:/wamp/www/data"; // the new path to root
foreach(glob("*.php") as $php_file) {
$data = file_get_contents($php_file);
$data = str_replace($toreplace,$replace,$data);
file_put_contents($php_file,$data);
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.