Home >Backend Development >PHP Tutorial >There is no page output after the sub-function is called.
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>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>
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>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>
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>
The method you have here should be slef::method,$this->method $obj->method, right?
Your B function has neither return nor echo