Okay, I have 2 questions. First: When using a function within a string do I need to place the entire function within ()parenthesis? echo 'this is what I mean'.ceil($num/4); or echo 'this is what I mean'.(ceil($num/4); The second question is even though PHP doesn't require variables to be declared as integer or string or etc, can I mix them when concantonating a string, like in the above examples? Or do I have to convert the digit into a string first?
first example is correct, and variables can be whatever, php is pretty clever for the most part, typically though int would be defined without quotation marks of any sort $var = 2; hope that helps.....
One question that I forgot to ask, when doing math within a string, do you surround that with ()parenthesis? a$=b$.(c$+1); or a$=b$.c$+1;
urm neither of them are correct, to do maths with strings : <? $a = 4; $b = 8; $c = 3; $e = 15; $sum = ($a * $b) + $c; // $sum = (4 * 8) + 3 // echo $sum : output 35 $sum = ( $c + $a ) * $b; // $sum = ( 3 + 4 ) * 8 // echo $sum : output 56 ?> PHP: got it ?
What I mean, is in this case: $b='String_Text'; $c=3; $a=$b.$c+3; or $b='String_Text'; $c=3; $a=$b.($c+3); So the result I'm trying to get is "String_Text6" I want to concantonate the integer 6 to the end of the string "String_Text"
<? /* PHP will spit errors if you try to use the code you have above, or not errors but not numbers you can use Instead, use something like the code below */ $str = "String_Text"; $a = 2; $b = 3; echo $str . ( $a * $b ); ?> PHP: yeah, ou had it right in the second one you did, which I only just read properly, sorry, you got it....