嗨,我找到了这个脚本,当我使用普通的charcter时,它可以工作,但是当我尝试插入一些特殊的字符不工作时,我尝试了json逃脱,没有运气,有人能帮我什么问题吗?获得误差
Parse :语法错误,第20行中/var/www/html/autopost.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>");
?>发布于 2016-05-25 22:45:30
你注意到了吗
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>");https://stackoverflow.com/questions/37448813
复制相似问题