NapalM
Junior Poster
Posts: 40
|
Post by NapalM on Feb 2, 2011 19:35:42 GMT
Do you guys know of any ways maybe to have something like an string with a script inside of it?
like for example have a include within a string?
so like instead of having
if(file_exists($file)){ include('page.php'); }
have it run within an string?
$include = include('page.php'); if(file_exists($file)){ echo $include; }
the problem is the echo right? because that is running to show it as text, not to run something. right?
|
|
russellr
Elite Level 1
[M:5000]
rCs?
Posts: 525
|
Post by russellr on Feb 2, 2011 20:19:15 GMT
Why not just use the include line?
What is the context here?
|
|
NapalM
Junior Poster
Posts: 40
|
Post by NapalM on Feb 2, 2011 21:05:13 GMT
Like thats just an example but what if i have a long script that does something but i want to just use the string instead of posting the whole script within that section.
|
|
xcessive
Epic Poster
.[M:5000]
Posts: 526
|
Post by xcessive on Feb 3, 2011 1:14:23 GMT
Open the file and edit it, THEN include it. Or if you don't want to perminantely modify it. Load it, modify the loaded file and resave it as temp.php, then include it.
|
|
NapalM
Junior Poster
Posts: 40
|
Post by NapalM on Feb 3, 2011 3:21:36 GMT
ah you guys arnt getting what im saying nvm haha. it was just a quick stupid question with no point really.
|
|
xcessive
Epic Poster
.[M:5000]
Posts: 526
|
Post by xcessive on Feb 3, 2011 3:32:19 GMT
What you want is an internal interpreter right? Well the problem is you shouldn't do this in PHP since php is already an interpreted language it would be extremely slow, not to mention pointless. I guess if you really wanted you could write a simple C server side app that calls the Zend engine or something to execute your included script. But all this is a little superfluous in my opinion.
Its actually a good question, the problem is that PHP is a bad language for reinterpreting itself.
I don't know why you dont just use functions or even OOP for this though? Or is there something specific you need to do which doesn't work with these approaches?
|
|