-3

私はから解析エラーを取得しています:

$uphalfh = if(isset($price30in)) { echo $price30in->textContent;}
if(isset($price30out)) { echo ", " . $price30out->textContent; }

解析エラーを回避するためにこのコードを改善するにはどうすればよいですか? $var で IF ステートメントを使用できないことを理解しています

Echo Variable の魅力のように動作すると、必要な結果が得られます。しかし、 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);
4

6 に答える 6

0

簡単な編集でうまくいきました!それは私の問題を解決しました:-)

私は置き換えました:

$uphalfh = if(isset($price30in)) { echo $price30in->textContent;}
if(isset($price30out)) { echo ", " . $price30out->textContent; }

これとともに:

$uphalfh = $price30in->textContent. ', ' . $price30out->textContent;
于 2013-10-14T14:56:31.207 に答える