Page 1 of 1

function........

Posted: Fri Nov 19, 2004 8:24 am
by dull1554
heres what i have

Code: Select all

<?php
session_start();
$_SESSION['1'] = "";
$_SESSION['2'] = "";
$_SESSION['3'] = "";
$_SESSION['4'] = "";
$_SESSION['5'] = "";
$_SESSION['6'] = "";
$_SESSION['7'] = "";
$_SESSION['8'] = "";
$_SESSION['9'] = "";
function buildarray($one = $_SESSION['1'],$two = $_SESSION['2'],$three = $_SESSION['3'],$four = $_SESSION['4'],$five = $_SESSION['5'],$six = $_SESSION['6'],$seven = $_SESSION['7'],$eight = $_SESSION['8'],$nine = $_SESSION['9']) {
    $board = array(array($one,$two,$three),array($four,$five,$six),array($seven,$eight,$nine));
    return $board;
}
?>
i get a parse error and i dont know whats wrong

Code: Select all

Parse error: parse error, unexpected T_VARIABLE in c:\program files\apache group\apache\htdocs\tictactoe.php on line 13
maybe you cant set a function var to another var and if this is the case does anyone konw a way around it

or another way of doing what im trying to do,

its gonna be a little tic tac toe game, i use a multi-demensional array and all i want to do is set each value in the array to a value that my or maynot have been set yet, i know that the way i have it now everytime i run it it will reset all those session vars to "" but ill fix that when i come to it

thanks in advance

Posted: Fri Nov 19, 2004 9:12 am
by Wayne
PHP manual says => The default value must be a constant expression, not (for example) a variable or class member.
why dont you assign the values $one = $_SESSION['1'] inside the function?

Posted: Fri Nov 19, 2004 9:16 am
by dull1554
dangit
i did not see that in the manual, either that or its an update or sumthin, i use the windows help file.....

Posted: Fri Nov 19, 2004 2:47 pm
by dull1554
i suppose i could do that.....