我从以下位置收到解析错误:
$uphalfh = if(isset($price30in)) { echo $price30in->textContent;}
if(isset($price30out)) { echo ", " . $price30out->textContent; }
如何改进此代码以避免 Parse 错误?我知道我不能在 $var 中使用 IF 语句
当我回显变量时,它的作用就像一个魅力,我得到了我想要的结果。但是我怎样才能将Echo 变量的结果(第 10 行)分配给 $uphalfh
include_once './wp-config.php';
include_once './wp-load.php';
include_once './wp-includes/wp-db.php';
// A name attribute on a <td>
$price30in = $xpath->query('//td[@class=""]')->item( 1);
$price30out = $xpath->query('//td[@class=""]')->item( 2);
// Echo Variable's
if(isset($price30in)) { echo $price30in->textContent;} if(isset($price30out)) { echo ", " . $price30out->textContent; }
// The wrong CODE i tried:
// $uphalfh = if(isset($price30in)) { echo $price30in->textContent;}
// if(isset($price30out)) { echo ", " . $price30out->textContent; }
// Create post object
$my_post = array();
$my_post['post_title'] = 'MyTitle';
$my_post['post_content'] = 'MyDesciprion';
$my_post['post_status'] = 'draft';
$my_post['post_author'] = 1;
// Insert the post into the database
$post_id = wp_insert_post( $my_post );
update_post_meta($post_id,'30_min',$uphalfh);