开发者

php how to scan full page for all POST variables and then echo at top of page?

I can't echo my variable above my CMS include code.. but if I echo the variable after, then it recognizes the $url variable.

Here is some code:

    <?php
    // here is my CMS inlcude code
    $template = 'news_script'; 
    $number = '';
    $category = '';  
    include $cutepath.'/show_news.php'; 

   ?>

If I echo $url above the include code, it returns nothing. But below, it 开发者_StackOverflow中文版obviously recognizes it.

Is there a php function that scans the whole page and retrieves all the POST variables so you can use $url at the top of the php page with a header('Location:'. $url); script??


Obviously $url is being defined in your show_news.php script. PHP executes a script line-by-line, and will not magically "reach back" to set a variables value in an earlier line.


Another (ugly) way would be:

<?php
  // here is my CMS inlcude code
  $template = 'news_script'; 
  $number = '';
  $category = '';  
  ob_start();
  include $cutepath.'/show_news.php'; 
  $buffered_data=ob_get_contents();
  ob_end_clean();
  echo $url; // here you could place your: header('Location:'. $url);
  echo $buffered_data;
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜