|
Subject:
|
Parse Error :-(
|
|
Posted By:
|
dean_custom
|
Post Date:
|
2/10/2004 4:43:35 PM
|
Parse error: parse error, unexpected T_ECHO
my code is as follows....
<? php echo '<h2>Hello</h2>' ?>
i have also tried....
<? php echo 'hello'; ?>
both times i get the same error "Parse error: parse error, unexpected T_ECHO"
I'm running IIS v5.1 and PHP ( maybe there's some IIS configuration i need to change??... HELP!!.. i'm PHP'd OFF
|
|
Reply By:
|
richard.york
|
Reply Date:
|
2/10/2004 4:59:19 PM
|
A parse error always means an error in code syntax, or a typo.
In your case the typo is in the opening <?php delimiter, you have a space between '<?' and 'php'... remove the space.
: ) Rich
::::::::::::::::::::::::::::::::: Smiling Souls http://www.smilingsouls.net :::::::::::::::::::::::::::::::::
|
|
Reply By:
|
dean_custom
|
Reply Date:
|
2/10/2004 10:30:17 PM
|
*MSG TO SELF* You're a moron. Why don't you pay attention to syntax you idiot!! lol.... I have another question now... how do you initialize variables in PHP? I'm doing ..
$IpAddress = env(REMOTE_ADDR);
it works and all.. but it says REMOTE_ADDR wasn't initalized or something... i tried java style and c style code..but i think i'm just too stupid.... lmao
|
|
Reply By:
|
richard.york
|
Reply Date:
|
2/11/2004 1:12:43 AM
|
lol, that's ok. I can remember being a beginner too.
PHP doesn't require variable initialization. A variable is intialized when it is created, and PHP automatically attempts to figure out what you intend the type to be based on the context with which it is used.
If you compare a variable and it is not initialized PHP will automatically, temporarily, create a copy of the varible in memory with NULL value for comparison purposes, if you aren't using certain language constructs (like isset and empty) PHP may complain in the form of a notice level error which happens with variables, arrays and constants when used before created.
PHP compares most closely with PERL, IMO, while the control structures are very similar to what you would find in C and Java.
Here is easily the most helpful URL you'll need when dealing with PHP: http://www.php.net/manual/en/
Start at the top, you can probably skip section I, but section II contains basic information about how variables may be used, security, control structures, predefined variables, all the basics. Its pretty dry reading, it doesn't do much hand holding, but there is a wealth of information in there.
That being said, you can get the remote address from the $_SERVER superglobal, which contains a set of predefined variables set by the HTTP SERVER.. the indices in this array aren't gauranteed to be the same between different HTTP servers,
Reference it like this:
echo $_SERVER["REMOTE_ADDR"];
Your script: $IpAddress = env(REMOTE_ADDR);
The program will look for a user-defined function named 'env' and attempt to pass the constant REMOTE_ADDR to it. Constants in PHP are just like variables, but they can be set only once, do not have a dollar sign, and must be set using the built in define() function. If a constant is used before being set it is assumed the string literal, PHP will complain in the form of a notice level error and continue on with execution. In your case you probably got a fatal error from 'env' not being a defined function.
You can use this script to find variables set in the array:
<?php phpinfo(); ?>
This prints out a detailed output of configuration and enviornment settings.
Additionally, the PHP manual notes those indices which can be expected to appear in the array: http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server
Here is the specific URL for predefined variables: http://www.php.net/manual/en/language.variables.predefined.php
::::::::::::::::::::::::::::::::: Smiling Souls http://www.smilingsouls.net :::::::::::::::::::::::::::::::::
|