意外的“意外”}“”
问题描述:
当我尝试去我的本地站点,上传新主题后,我收到消息: 解析错误:语法错误,意外的'}'在C:\ wamp \ www \ test03 \可湿性粉剂内容\主题\海泽拉\ INC \上线52意外的“意外”}“”
这一切都对pdf.php是代码:
<? function to_pdf_form(){ ?>
<form method="post" action="">
<input style="margin-top:20px;" class="button" type="submit" name="submit-all-to-pdf" value="Upload all products to PDF!">
</form>
<p>Files uploaded to /wp-content/uploads/products-pdf.</p>
<?php
if (isset($_POST['submit-all-to-pdf'])){
ini_set('max_execution_time', 300);
global $post;
$args = array('post_type' => 'product', 'posts_per_page' => -1);
$the_product = get_posts($args);
foreach($the_product as $post) {
$product_id = get_the_ID();
$product_name = get_the_title ($product_id);
if(class_exists('Pdfcrowd')){
if (!$product_id) die();
$pdf_version_url = add_query_arg(array('pdf_version' => 1), get_permalink($product_id));
$wp_upload_dir = wp_upload_dir();
if (!file_exists($wp_upload_dir['basedir'] . '/products-pdf')) {
mkdir($wp_upload_dir['basedir'] . '/products-pdf', 0777, true);
}
$pdf_file_name = 'product-' . $product_id . '.pdf';
$pdf_file_path = $wp_upload_dir['basedir'] . '/products-pdf/' . $pdf_file_name;
try
{
// create an API client instance
$client = new Pdfcrowd("username", "password");
if (file_exists($pdf_file_path)) continue;
$out_file = fopen($pdf_file_path, "wb");
$client->setHtmlZoom("120");
$client->convertURI($pdf_version_url, $out_file);
fclose($out_file);
// send the generated PDF
echo '<strong>' . $product_name .' uploaded successfully. </strong><br/>';
}
catch(PdfcrowdException $why)
{
echo "Pdfcrowd Error: " . $why . "<br/>";
}
}
}
}
}
?>
我看不出有什么错在这里。
谢谢
答
编辑:
您正在使用短开放标签像这样:
<? function to_pdf_form(){ ?>
改变这种
<?php function to_pdf_form(){ ?>
,你不应该有任何的问题。
这是不对的,忽略它:
您有一个额外的收盘}
这里,删除它
catch(PdfcrowdException $why)
{
echo "Pdfcrowd Error: " . $why . "<br/>";
}
//}