PHP函数运行时间
样的一个基本问题,但我有类似于此示例页面:PHP函数运行时间
<?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(); ?>
编辑:
我已经更新了代码,以反映确切的代码我使用。
为什么someFunction
函数中的myFunction
echo
输出出现在文档的底部,而不是$somestring
之后?
如何更改此代码,以便myFunction
echo
输出显示在正确的位置?
我相信它跟你的Wordpress主题有关。我在我的WordPress博客上测试过它,效果很好。函数在我执行它的地方回显值。请检查您的header.php
。我认为d3v3us是正确的,并且与输出缓冲有关。
实际上,我刚刚使用了默认的Wordpress主题,我使用exec-php插件来运行代码,我从帖子内部调用函数,但仍然在页脚底部获得底部结果。 – 2012-01-04 19:55:10
模具exec-php有一个页脚钩?如果是这样,您的代码将始终显示在页面的末尾。 – sascha 2012-01-05 07:42:38
你确定没有任何调用来输出缓冲功能吗? 'ob_X',就像'ob_start','ob_flush'等等。 – sberry 2012-01-03 21:48:22
是你正在使用的**精确**代码,它有描述的问题吗? – sascha 2012-01-03 21:49:29
@ SnOopy你是对的,我应该添加原始代码。我编辑了我的帖子。 – 2012-01-03 21:53:06