dsjswclzh40259075
2016-08-08 06:42
浏览 24
已采纳

如何在PHP中回显定义值?

My code is here:

<?php define("SITENAME","Page TITLE");?>

I want to echo define value like:

<?php echo "<?=SITENAME?>";?>

Would someone tell me how?

图片转代码服务由CSDN问答提供 功能建议

我的代码在这里:

 &lt;?php define  (“SITENAME”,“Page TITLE”);?&gt; 
   
 
 

我想回显定义值,如:

  &lt;?php echo“&lt;?= SITENAME?&gt;”;?&gt; 
   
 
 

有人会告诉我怎么做? \ n

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongshengheng1013 2016-08-08 06:52
    已采纳

    Here you go:

    <?php 
        define("SITENAME","Page TITLE");    
        echo "My website title: ".SITENAME; 
    ?>
    

    output : My website title: Page TITLE

    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • doufeixi6014 2016-08-08 06:49

    You can echo the value of constant as below

    define("SITENAME","Page TITLE");
    echo SITENAME.': My New Content Here';
    

    This gives : Page TITLE: My New Content Here

    For more reference:

    define("CONSTANT", "Hello world.");
    echo CONSTANT; // outputs "Hello world."
    echo Constant; // outputs "Constant" and issues a notice.
    
    define("GREETING", "Hello you.", true);
    echo GREETING; // outputs "Hello you."
    echo Greeting; // outputs "Hello you."
    
    // Works as of PHP 7
    define('ANIMALS', array(
        'dog',
        'cat',
        'bird'
    ));
    echo ANIMALS[1]; // outputs "cat"
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题