简体   繁体   English

文件包括从Linux到Windows

[英]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.

相关问题 使用php从Linux将文件下载到Windows时修复文件结尾编码 - Fix file endcoding when downloading a file from Linux to Windows in php 从Linux服务器运行.exe文件到Windows客户端? - Run .exe file from linux server to Windows client? 文件上传在Windows上有效,但在Linux上无效 - File upload works on windows, but not on linux PHP 包括停止文件上传 - PHP includes stops file from uploading 父文件夹包含的文件,另一个文件夹包含的文件 - Included file from a parent folder that includes a file from another folder 在通过网络共享连接的 Linux 服务器上创建文件 从 Windows - Create file on Linux-Server Connected through network share From Windows 将 PHP 项目从 Linux 服务器迁移到 Windows 服务器时,文件名中的斜线 - Slashes in file names when migrating PHP project to Windows server from Linux server 从csv文件导入数据的代码在Windows上有效,但在kali linux apache2中则无效。 每个答案都被赞美 - Code to import data from csv file works on windows but not in kali linux apache2. every answer is apriciated 上传文件时:仅在Linux上但在Windows上,Curl返回“来自服务器的空答复” - When upload file: Curl return “Empty reply from server” only on Linux but Windows linux等效于使用system()从PHP在Windows上运行.bat文件的Linux - What is linux equivalent of running a .bat file on windows from PHP using system()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM