hi there, I need help in creating a constant in php5. I'm following the example in the book. the code is: <html> <head> <title></title> </head> <body> <?php define<'greeting', 'hello'>; echo '<h1> . greeting . '<h1>; ?> </body> </html> the error code I get is Parse error: parse error, unexpected ',' in /home/content/f/r/e/freecss/html/aaa-practice-php.php on line 7
I am not 100% but is it not the same as php4 define("constant_name", "constant text"); Code (markup):
well, I do not know PHP4, so Im not sure. Im going straight from the book that I have which a tutorial on php5.
well the above is how you define a constant in all previous versions of PHP. They wouldn't have changed it so just try that out
I just confirmed on php.net that a constant is defined the same as in previous versions so your constant would be. define('greeting', 'hello'); echo "<h1>".greeting."</h1>"; Code (markup):
I see what I'm doing wrong. I used paranthesis greater than symbols instead of paranthesis in the first line of code. in the second line of code, I didn't surround the heading tags with " on both sides. thanks btw, if you don't me asking, where did you go on php.net to find that? again thanks
Go to php.net and in the 'search for' box type 'constant'. Alternatively, php.net has a great URL heirarchy. If you know a function name, for example, go to http://php.net/functionname and it will send you straight to it...