function........

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

function........

Post 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
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post 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?
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post 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.....
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

i suppose i could do that.....
Post Reply