English 中文(简体)
Edit xml是PHP的简单文本文档
原标题:Edit xml as simple text file in PHP

我想替换Xml文档中的服务器地址。 地址:%scr_path%

<property id="urlGenerateImage">%scr_path%/imgcap.php</property> 

采用以下守则

$path=$wsurl."core/contents/tests";
//read the entire string
$str=implode("
",file( ../includes/ckeditor/plugins/fmath_formula/dialogs/configMathMLEditor.xml ));

$fp=fopen( ../includes/ckeditor/plugins/fmath_formula/dialogs/configMathMLEditor.xml , w );
//replace something in the file string 
$str=str_replace( %scr_path% ,$path,$str);

//now, TOTALLY rewrite the file
fwrite($fp,$str,strlen($str));

找出错误档案道路上的错误。 封锁了两条道路。 什么错误?

最佳回答

这一切都取决于贵国的文字目录。 由于你重新使用相对路径名称(./),你最好能确保你知道目前使用的文字。 或者说,更糟的是,在你的发言稿一开始,它就会始终发挥作用。

$path = $wsurl."core/contents/tests";

// change directory to project root
chdir("/your/project/directory");

// read the file into a string
$filename =  includes/ckeditor/plugins/fmath_formula/dialogs/configMathMLEditor.xml ;
$str = file_get_contents($filename);

// replace token
$str = str_replace( %scr_path% ,$path,$str);

// save file
file_put_contents($filename, $str);
问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签