嗨,我发现这个脚本,当我使用普通的字符时,它工作,但当我尝试插入一些特殊的字符不起作用我试过json逃避没有运气可以有人帮我什么是错的? 得到错误
PHP Parse错误:语法错误,第20行/var/www/html/auto_post.php中的意外“http”(T_STRING)
<?php
require( 'wp-load.php' );
function simpleImportPost($title,$import_id,$content){
// Create post object
$my_post = array();
$my_post['post_title'] = $title;
$my_post['import_id']=$import_id;
$mypost['comment_status'] = 'closed';//I'll set all closed
$my_post['post_content'] = $content;
$my_post['post_status'] = 'publish';
$my_post['post_author'] = 1;
$my_post['post_category'] = array(0);
// Insert the post into the database
return wp_insert_post( $my_post );
}
$ch_name="Live_tv_1";
simpleImportPost("$ch_name",35,"<iframe src="http://site.xxx/jwplayer_6/elchourouk.html" style="width: 640px; height: 480px" scrolling="no" frameborder=0 ALLOWTRANSPARENCY="true" overflow:hidden; ></iframe>");
?>
答案 0 :(得分:0)
你注意到了
simpleImportPost("$ch_name",35,"<iframe src="http://site.xxx/jwplayer_6/elchourouk.html" style="width: 640px; height: 480px" scrolling="no" frameborder=0 ALLOWTRANSPARENCY="true" overflow:hidden; ></iframe>");
包含许多"
甚至此处的显示无法正确解析?
如果要在其他引号中嵌入引号,可以使用不同的引号('
vs "
)或使用反斜杠(\
)转义它们,例如:
simpleImportPost("$ch_name",35,"<iframe src='http://site.xxx/jwplayer_6/elchourouk.html' style='width: 640px; height: 480px' scrolling='no' frameborder=0 ALLOWTRANSPARENCY='true' overflow:hidden; ></iframe>");