Home > Backend Development > PHP Tutorial > There is no page output after the sub-function is called.

There is no page output after the sub-function is called.

WBOY
Release: 2016-08-04 09:21:50
Original
1245 people have browsed it

I wrote a function A and called function B to output a piece of html. But I found that as long as the B function is called, this html will not be output on the page.
If you copy this html directly into function A and block the call of function B, the html will be output.
What exactly went wrong?

A function code:

<code>public static function cartbinet_display_setting_html_page() {
    echo '<div class="wrap">';
    
    /*display xml data*/
    //$xmlfile = plugins_url( 'cartbinet-server/data/cartbinets.xml' );
    //$xml = simplexml_load_file($xmlfile);
    //var_dump($xmlfile);
    //var_dump($xml);
    //cartbinet_display_xml_data($xml);
    
    /*display setting content*/
    cartbinet_display_setting_page();
<?php        
    echo '</div>';
} 
</code>
Copy after login
Copy after login
The

B function is:

<code>public static function cartbinet_display_setting_page( ) {
    ?>
        <h2>Set Copyright</h2>   
        <form method="post" action="options.php">  
            <?php /* 下面这行代码用来保存表单中内容到数据库 */ ?>  
            <?php wp_nonce_field('update-options'); ?>  

            <p>  
                <textarea  
                    name="display_copyright_text" 
                    id="display_copyright_text" 
                    cols="40" 
                    rows="6"><?php echo get_option('display_copyright_text'); ?></textarea>  
            </p>  

            <p>  
                <input type="hidden" name="action" value="update" />  
                <input type="hidden" name="page_options" value="display_copyright_text" />  

                <input type="submit" value="Save" class="button-primary" />  
            </p>
        </form>  
    <?php  
    } </code>
Copy after login
Copy after login

Reply content:

I wrote a function A and called function B to output a piece of html. But I found that as long as the B function is called, this html will not be output on the page.
If you copy this html directly into function A and block the call of function B, the html will be output.
What exactly went wrong?

A function code:

<code>public static function cartbinet_display_setting_html_page() {
    echo '<div class="wrap">';
    
    /*display xml data*/
    //$xmlfile = plugins_url( 'cartbinet-server/data/cartbinets.xml' );
    //$xml = simplexml_load_file($xmlfile);
    //var_dump($xmlfile);
    //var_dump($xml);
    //cartbinet_display_xml_data($xml);
    
    /*display setting content*/
    cartbinet_display_setting_page();
<?php        
    echo '</div>';
} 
</code>
Copy after login
Copy after login
The

B function is:

<code>public static function cartbinet_display_setting_page( ) {
    ?>
        <h2>Set Copyright</h2>   
        <form method="post" action="options.php">  
            <?php /* 下面这行代码用来保存表单中内容到数据库 */ ?>  
            <?php wp_nonce_field('update-options'); ?>  

            <p>  
                <textarea  
                    name="display_copyright_text" 
                    id="display_copyright_text" 
                    cols="40" 
                    rows="6"><?php echo get_option('display_copyright_text'); ?></textarea>  
            </p>  

            <p>  
                <input type="hidden" name="action" value="update" />  
                <input type="hidden" name="page_options" value="display_copyright_text" />  

                <input type="submit" value="Save" class="button-primary" />  
            </p>
        </form>  
    <?php  
    } </code>
Copy after login
Copy after login

Would you get an error if you write like this? I’ll give it a try first...

Okay! There’s really no error!

<code><?php 

class Tpl {
  static function show() {
      echo "?:";
  ?>
    why?
  <?php 
  
  }
}

Tpl::show();</code>
Copy after login

The method you have here should be slef::method,$this->method $obj->method, right?

Your B function has neither return nor echo

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template