PHP Includes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rock54
    New Member
    • Mar 2008
    • 1

    PHP Includes

    Hey,

    I'm relatively new to PHP. I have programmed in C++ and JavaScript before.

    I have this piece of code that writes a value to a file.
    [PHP]$myFile = "minval.php ";
    $fh = fopen($myFile, 'w') or die("can't open file");;
    fwrite($fh, $minval);
    fclose($fh);[/PHP]

    The $minval is user defined and is an integer.

    Anyways, after I try to include the "minval.php " like this:
    [PHP]$order = include('minval .php');[/PHP]

    The minimum value is always 1 (because include() returns 1). I want it to return the value inside of minval.php, not 1.

    Anyone know how to do it?
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    If you want to include it, you must write the variable name inside, in an assign statement, like [php]fwrite($fh, '$order='.$minv al.';');[/php]

    Then you do not assign the included file, but just do the include[php]include('minval .php');[/php]Then the variable $order is available.

    Ronald

    Comment

    Working...