问题
I'm trying to make the command but I get an error..
URL Link:
http://www.site.com/page?Channel=EM
Datas.php
$EM_URL = "http://site.com/live/em...."
PageView.php
<? echo '$ ?><?php print $_GET['Channel']; print "_URL"; ?><?php '; ?>
Screen:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'
Where the error am I doing?
回答1:
I guess, what You're trying to do - to get part of the variables name from the URL ($_GET[]
). In this case You should do something like this:
<?php
$var = $_GET['Channel'] . '_URL';
echo($$var);
?>
NOTE:
I really doubt it's a good practice for security reasons. You should strip the input at least. Or use switch..case
blocks for all defined possible input variables.
Reference: 2nd example in PHP manual.
回答2:
<?php echo '$'; ?>
<?php print $_GET['Channel']; print "_URL"; ?>
<?php print "'"; ?>
来源:https://stackoverflow.com/questions/19388426/get-command-incorrect