Reputation: 121
i just stumbled across the weirdest thing that has ever happened to me in coding. I defined a variable $csslink = '../styles/global.css';
in php and call it in HTML via
<link rel='stylesheet' type='text/css' href='<?php echo $csslink; ?>' />
but it doesn't work. The page is displayed without the styles specified in global.css
.
Now when I put
echo $csslink;
after the definition of $csslink
and before the html, it works.
What the hell?
edit
It's only the case in Firefox (Chrome/IE work without the echo
) also it doesn't matter what I echo, if it's echo "xxx";
it still works.
edit2
I changed it to the long <?php
tag, doesn't make a difference though.
Upvotes: 2
Views: 109
Reputation: 2638
I would use:
<link rel='stylesheet' type='text/css' href='<?php echo $csslink; ?>' />
Upvotes: 0
Reputation:
they are ASP tags.
Try with PHP short open tags:
<link rel='stylesheet' type='text/css' href='<?=$csslink?>' />
If this is also not working try with PHP normal tags:
<link rel='stylesheet' type='text/css' href='<?php echo $csslink; ?>' />
Upvotes: 0
Reputation: 3819
Try <?=$csslink?>
. I guess <% %>
is ASP syntax, not PHP.
If it still doesn't work, ensure, that ALLOW_SHORT_TAGS in php.ini is on.
Upvotes: 1