I would like to know how can i use variable here instead of constant. for ex I have this statement
<link rel="stylesheet" type="text/css" href="<?php echo $this开发者_JS百科->getSkinUrl('css/abc.css')?>"/>
Now Instead of abc.css , I want tomake it variable instead of hardcode value
like $A = "abc.css" ;
So statement should look like ==>
$A = "abc.css" ;
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/$A')?>"/>
Please guide me, I'm not able to do it.
<?php $A = "abc.css" ; ?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl("css/$A")?>"/>
Variables within double quoted strings are replaced.
Only code between <?php
and ?>
marks is considered and processed as PHP code. And you placed $A = "abc.css" ;
outside these marks. So the code in <link>
tag is trying to work with undeclared variable.
Also, only variables in double quoted strings are replaced.
Another way:
<?php $A = "abc.css" ; ?>
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/'.$A)?>"/>
精彩评论