Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to echo href with php function inside?

Tags:

php

href

echo

How to echo this:

echo '<link rel="stylesheet" type="text/css" href="<?php echo get_bloginfo('template_url');?>/tryme.css">';

Am I doing right? It gets an error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'

Please help. THank you.

like image 436
baby Avatar asked Mar 23 '26 10:03

baby


1 Answers

echo '<link rel="stylesheet" type="text/css" href="' . get_bloginfo('template_url') . '/tryme.css">';

echo is a function, which prints its argument. You can actually call echo like this: echo("hello");, which is syntactically identical to echo "hello";

if you are calling echo, you are already in php mode (ie: there's an open <?php somewhere before your echo call), so there's no need to enter php mode again for the get_bloginfo call. get_bloginfo returns a string, so you can just concatenate its output with the rest of your echo parameter.

like image 53
smcphill Avatar answered Mar 25 '26 01:03

smcphill