Guest Cashster09 Posted May 24, 2009 Report Share Posted May 24, 2009 i have uploaded this to my server and it worked but wondered why? I didnt use quotes around the names ["Bob"] and it still output The salary of Bob is $1000 I know you dont need quotes around the numeric values of 1000, 2000, and 3000 but i thought u did around the names in brackets. I'm new at this.... <?php $salaries [bob] = 1000; $salaries [Rich] = 2000; $salaries [John] = 3000; echo "The salary of Bob is $" . $salaries [bob]; ?> Quote Link to comment Share on other sites More sharing options...
jlhaslip Posted May 24, 2009 Report Share Posted May 24, 2009 $this_variable = "This Variable"; echo "This part " . $this_variable . " and another part. "; echo 'This part ' . $this_variable . ' and another part. '; echo "This part $this_variable and another part. "; ?> The example you have uses the concatenation operator, like the first and second example I posted. The Third line above has the variable embedded inside double quotes, which gets parsed as the variable contents. The echo with single quotes do not get parsed as php code, so it actually runs quicker on the Server. Also, to ensure that your code will work on more Servers without difficulties, I suggest that you add the single quotes inside the square Array brackets. $salaries ['Bob']; Quote Link to comment Share on other sites More sharing options...
zamshed Posted June 17, 2009 Report Share Posted June 17, 2009 In your problem, Bob was passed a parameter, so the porblem has been occured. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.