Click to See Complete Forum and Search --> : Variable question
comptech520
01-14-2008, 02:31 PM
Can I declare a variable like this?
$java='<?php include('javacheck.php')?>';
I want to have a field that will contain some information that will be sent to a support represenative that the user will not see.
I want to send the contents of javacheck.php
This is what it would look like on my form. How can I make this happen?
<input type="hidden" name="javascript" value="$java">
scragar
01-14-2008, 03:02 PM
unfortunatly, include returns it's own value, so you cannot set it like that...
you could write a function in the include file and call the function to return a value, or echo the content from the include to the output, and use various buffer functions to read this in, then clear the information.
comptech520
01-14-2008, 03:16 PM
This is the file that I want to include in the email to the support rep.
I want to have it hidden though.
scragar
01-14-2008, 03:36 PM
that's more a question of rewriting the code to just put hidden form elements around the content. Once that is done you can rebuild the content using PHP.
there are other methods of doing it involving frames and such, but that's anything but a perfect solution.
katten
01-15-2008, 06:01 AM
You can assign a include to a varible IF the included files has a return statement containg what you want to return
Example
included_file.php
// English template lanage file example.
$language = array(
'hello' => 'Greetings',
'bye' => 'Good bye'
);
return $language;
Index.php
$language = include('included_file.php');
// language will now contain the array :)
I do not think this is a very good idea tho