So basically I have a file, lets say file1.php
and it includes another file2.php
.
file1.php
contains a variable called $dateString
that I have performed some operations on.
file2.php
also has the same variable called $dateString
however this variable is not being referenced within this include file even though $dateString
was initialized prior to including file2.php
.
So this is currently how file1.php
looks like:
$dateString = 'some expression';
include 'file2.php';
file2.php
is basically trying to echo out the variable that was initialized in file1.php
echo $dateString;
Everything else from file2.php
is being called properly except that one variable.
Hopefully this makes sense. Is this possible in PHP? I have read in other places that you need to make the variables global and others have mentioned how you cant reference a variable from a parent file within a child file..any thoughts? Thanks in advance!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…