soryn4u Posted August 23, 2007 Share Posted August 23, 2007 I have this code.... a.php ----------- <?php $a = 'dog'; ?> b.php ----------- <?php $b = $a; echo $b; ?> How do I make the variable $a available in b.php? Link to comment https://forums.phpfreaks.com/topic/66335-solved-variabile-into-a-variabile-to-other/ Share on other sites More sharing options...
MadTechie Posted August 23, 2007 Share Posted August 23, 2007 a.php ----------- <?php $a = 'dog'; ?> b.php ----------- <?php include "a.php"; $b = $a; echo $b; ?> Link to comment https://forums.phpfreaks.com/topic/66335-solved-variabile-into-a-variabile-to-other/#findComment-331852 Share on other sites More sharing options...
trq Posted August 23, 2007 Share Posted August 23, 2007 Even better, use sessions. a.php <?php session_start(); $_SESSION['a'] = 'dog'; echo "<a href='b.php'>b</a>"; ?> b.php <?php session_start(); $b = $_SESSION['a']; echo $b; ?> Link to comment https://forums.phpfreaks.com/topic/66335-solved-variabile-into-a-variabile-to-other/#findComment-331938 Share on other sites More sharing options...
soryn4u Posted August 23, 2007 Author Share Posted August 23, 2007 <?php include "a.php"; $b = $a; echo $b; ?> this code is not so good becouse if i have in a.php some extra lines with rows.. i would not want to load into b.php page -------------- thanks thorpe with session my page work excelent Link to comment https://forums.phpfreaks.com/topic/66335-solved-variabile-into-a-variabile-to-other/#findComment-331960 Share on other sites More sharing options...
MadTechie Posted August 23, 2007 Share Posted August 23, 2007 lol, you could said that in the first post, the more details we have to play with the better the responce, word of warning about sessions, you MUST have session_start(); at the start of the page BEFORE sending any text/data to the screen, ie (this will fail) echo "ahhh"; //<-- bad line session_start(); $_SESSION['a'] = 'dog'; echo "<a href='b.php'>b</a>"; Link to comment https://forums.phpfreaks.com/topic/66335-solved-variabile-into-a-variabile-to-other/#findComment-331965 Share on other sites More sharing options...
soryn4u Posted August 23, 2007 Author Share Posted August 23, 2007 yes but i can put like this and it works in ie <?php session_start(); echo "ahhh"; echo "ahhh"; echo "ahhh"; echo "ahhh"; echo "ahhh"; $_SESSION['a'] = 'dog'; echo "<a href='b.php'>b</a>"; echo "ahhh"; echo "ahhh"; echo "ahhh"; echo "ahhh"; echo "ahhh"; ?> Link to comment https://forums.phpfreaks.com/topic/66335-solved-variabile-into-a-variabile-to-other/#findComment-331997 Share on other sites More sharing options...
MadTechie Posted August 23, 2007 Share Posted August 23, 2007 Yep, just giving you the heads up Link to comment https://forums.phpfreaks.com/topic/66335-solved-variabile-into-a-variabile-to-other/#findComment-332014 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.