简体   繁体   English

PHP函数运行时间

[英]PHP function run time

Kind of a basic question, but I have a page similar to this example: 有点基本的问题,但是我有一个类似于以下示例的页面:

<?php 
/*
Template Name: Temp
*/
?>

<?php
function myFunction($urls) {
    $q = mysql_query("SELECT * FROM table");
    while ($row = mysql_fetch_array($q)) {
       echo $row['field'];
    }
}

$url1 = $_POST['urls'];
$urls = explode("\r\n",$url1);
?>
<?php get_header(); ?>
    <?php if (get_option('professional_integration_single_top') <> '' && get_option('professional_integrate_singletop_enable') == 'on') echo(get_option('professional_integration_single_top')); ?> 

    <div id="content-top" class="top-alt"></div>
    <div id="content" class="clearfix content-alt">
        <div id="content-area">
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
            <?php get_template_part('includes/breadcrumbs'); ?>

            <?php if (get_option('professional_integration_single_top') <> '' && get_option('professional_integrate_singletop_enable') == 'on') echo(get_option('professional_integration_single_top')); ?>

            <div class="entry clearfix post">
            <?php
                        myFunction($urls);           
                ?>
                <h1 class="title"><?php the_title(); ?></h1>

                <?php if (get_option('professional_page_thumbnails') == 'on') { ?>

                    <?php $thumb = '';
                    $width = 184;
                    $height = 184;
                    $classtext = '';
                    $titletext = get_the_title();

                    $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext);
                    $thumb = $thumbnail["thumb"]; ?>

                    <?php if($thumb <> '') { ?>
                        <div class="thumb alignleft">
                            <?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
                            <span class="overlay"></span>
                        </div> <!-- end .thumb -->
                    <?php }; ?>

                <?php }; ?>

                <?php the_content(); ?>
                <?php wp_link_pages(array('before' => '<p><strong>'.esc_html__('Pages','Professional').':</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
                <?php edit_post_link(esc_html__('Edit this page','Professional')); ?>

            </div> <!-- end .entry -->

            <?php if (get_option('professional_integration_single_bottom') <> '' && get_option('professional_integrate_singlebottom_enable') == 'on') echo(get_option('professional_integration_single_bottom')); ?>

            <?php if (get_option('professional_show_pagescomments') == 'on') comments_template('', true); ?>
        <?php endwhile; endif; ?>
        </div> <!-- end #content-area -->

        <?php get_sidebar(); ?>

    </div> <!-- end #content -->
    <div id="content-bottom" class="bottom-alt"></div>

<?php get_footer(); ?>

EDIT : 编辑

I have updated the code to reflect the exact code I'm using. 我已经更新了代码以反映我正在使用的确切代码。

Why are the myFunction echo outputs within the someFunction function are appearing at the bottom of the document instead of right after $somestring ? 为什么someFunction函数中的myFunction echo输出出现在文档的底部,而不是出现在$somestring

How can I change this code so the myFunction echo outputs will appear in the correct place? 如何更改此代码,以便myFunction echo输出将出现在正确的位置?

I believe it has something to do with your Wordpress theme. 我相信这与您的Wordpress主题有关。 I tested it on my Wordpress blog and it works well. 我在Wordpress博客上对其进行了测试,并且效果很好。 The function echos the value on the place I executed it. 该函数在执行它的地方回显该值。 Please check your header.php . 请检查您的header.php I think d3v3us is right and is something to do with output buffering. 我认为d3v3us是正确的,并且与输出缓冲有关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM