[英]PHP function run time
有點基本的問題,但是我有一個類似於以下示例的頁面:
<?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是正確的,並且與輸出緩沖有關。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.