Newbe PHP: I'm haveing trouble running simple example code
I'm trying to get some PHP example code to work on PHP version 5.3.4, Apache 2.2.17 on Windows.
The example says I need PHP 4.0 and above with CURL and contains:
<?
$function = $_GET['function-if-exist'];
$test = "Test";
?>
<? =$test ?>
I don't understand why I'm getting the following errors:
Can anyone help me understand why their code is not working for me?
1) <?
is the "short tag". Most servers are configured to not allow short tags. This can be changed in php.ini
.
2) Again, short tags. Also I think you can't have a space before the =
, but the main problem is the short tags setting.
3) $_GET
accesses the query string, so when loading your script you need myscript.php?function-if-exist=something
在继续防止错误被抛出之前检查参数是否被设置是比较理想的,例如
if(isset($_GET['function-if-exist']))
{
$functionexists = $_GET['function-if-exist'];
}
上一篇: 使用R的零零假设