Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php “意外”;意外的';}'&引用;_Php_Wordpress - Fatal编程技术网

Php “意外”;意外的';}'&引用;

Php “意外”;意外的';}'&引用;,php,wordpress,Php,Wordpress,当我尝试访问我的本地站点时,在上传新主题后,我收到以下消息: 分析错误:语法错误,第52行的C:\wamp\www\test03\wp content\themes\hazera\inc\all-to-pdf.php中出现意外“}” 代码如下: <? function to_pdf_form(){ ?> <form method="post" action=""> <input style="margin-top:20px;" class=

当我尝试访问我的本地站点时,在上传新主题后,我收到以下消息: 分析错误:语法错误,第52行的C:\wamp\www\test03\wp content\themes\hazera\inc\all-to-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/>";
            }
            }
        }
    }   
}
?>

文件上载到/wp content/uploads/products pdf

我看不出这里出了什么问题

谢谢

编辑:

您正在使用短的打开标记,例如:

<? function to_pdf_form(){ ?>
<?php function to_pdf_form(){ ?>
catch(PdfcrowdException $why)
    {
        echo "Pdfcrowd Error: " . $why . "<br/>";
    }
    //}