willdk Posted May 4, 2009 Share Posted May 4, 2009 ??? I have two php files. index.php with an include: <?php include "/web/site/domains/mydomain.tld/public_html/include-me.php"; ?> include-me.php: <?php $arrPHP = array(); $arrPHP[] = '.$from = array("<a href=, ","spam"); $to = array("",""); $page = "/web/site/domains/mydomain.tld/public_html/files/test.php"; ........ echo $result;.' echo $arrPHP; ?> Why is this not working? I want to execute the php script, using an include. Quote Link to comment https://forums.phpfreaks.com/topic/156781-solved-include-php-file-with-includes-array-not-working/ Share on other sites More sharing options...
wildteen88 Posted May 4, 2009 Share Posted May 4, 2009 Your code makes no sense. Why you putting PHP code within an array? PHP is not executed from within strings. You need to use eval in order for code within strings to execute. Also as $arrPHP is an array, just echo'ing it on its own will result in Array being displayed, Quote Link to comment https://forums.phpfreaks.com/topic/156781-solved-include-php-file-with-includes-array-not-working/#findComment-825607 Share on other sites More sharing options...
.josh Posted May 4, 2009 Share Posted May 4, 2009 considering he forgot the semicolon on the line before the echo, it won't even do that. Quote Link to comment https://forums.phpfreaks.com/topic/156781-solved-include-php-file-with-includes-array-not-working/#findComment-825608 Share on other sites More sharing options...
willdk Posted May 4, 2009 Author Share Posted May 4, 2009 considering he forgot the semicolon on the line before the echo, it won't even do that. If you mean the '..........', it's just to shorten the code. Quote Link to comment https://forums.phpfreaks.com/topic/156781-solved-include-php-file-with-includes-array-not-working/#findComment-825611 Share on other sites More sharing options...
willdk Posted May 4, 2009 Author Share Posted May 4, 2009 Your code makes no sense. Why you putting PHP code within an array? PHP is not executed from within strings. You need to use eval in order for code within strings to execute. Also as $arrPHP is an array, just echo'ing it on its own will result in Array being displayed, 'eval' is new to me. Thank you I try to convert the code to work with this function. Quote Link to comment https://forums.phpfreaks.com/topic/156781-solved-include-php-file-with-includes-array-not-working/#findComment-825612 Share on other sites More sharing options...
wildteen88 Posted May 4, 2009 Share Posted May 4, 2009 Why is your PHP code within an array in the first place? Quote Link to comment https://forums.phpfreaks.com/topic/156781-solved-include-php-file-with-includes-array-not-working/#findComment-825629 Share on other sites More sharing options...
willdk Posted May 4, 2009 Author Share Posted May 4, 2009 Why is your PHP code within an array in the first place? I saw a script with php include in the array. So I thought I could make that script work in that way. Sometimes I think I now the basics of php, but then I realise I'm still a html-guy I'm still trying out that eval function. There goes my day Quote Link to comment https://forums.phpfreaks.com/topic/156781-solved-include-php-file-with-includes-array-not-working/#findComment-825649 Share on other sites More sharing options...
Ken2k7 Posted May 4, 2009 Share Posted May 4, 2009 $some_php = "$e = 4; echo $e;"; eval($some_php); Quote Link to comment https://forums.phpfreaks.com/topic/156781-solved-include-php-file-with-includes-array-not-working/#findComment-825669 Share on other sites More sharing options...
willdk Posted May 5, 2009 Author Share Posted May 5, 2009 $some_php = "$e = 4; echo $e;"; eval($some_php); cool TY Ken2k7! Quote Link to comment https://forums.phpfreaks.com/topic/156781-solved-include-php-file-with-includes-array-not-working/#findComment-826785 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.