How to pass php variable to include page? -


when load page index.php, why not echo $my_header

index.php

<?php include 'test.php'; $my_header = 'aaaaaaaaaaaaaaaaaaaa'; ?> 

test.php

<?php echo $my_header; ?> 

just change 2 lines this:

$my_header = 'aaaaaaaaaaaaaaaaaaaa'; include 'test.php'; 

also version should give error! if not recommend turn error reporting on this:

<?php     error_reporting(e_all);     ini_set("display_errors", 1); ?> 

(btw: recommend use require_once script included once , errors!)

see: http://php.net/manual/en/function.require-once.php


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -