GET & Command - Incorrect

有些话、适合烂在心里 提交于 2019-12-11 16:23:18

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!