开发者

Using PHP inside HTML

开发者 https://www.devze.com 2023-03-17 10:54 出处:网络
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

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)?>"/>
0

精彩评论

暂无评论...
验证码 换一张
取 消