I’m just getting into PHP and really don’t know much. I’m trying to figure out how to create a shortcode tag. I’m not sure if that is the correct term for it but below is what I’m talking about.
I want this:
<?php echo $myVariable; ?>
… to look something like this:
{myVariable}
or
[myVariable]
Is there a simple way to do this with PHP code? Any help would be appreciated!
Or <?=$someVariable?>
(requires short_open_tag to be enabled in php.ini, which it is by default)
Simply do this
<?php
echo "{$myVariable}";
?>
The {} are superfluous in that statement since $myVariable and {$myVariable} are two different ways of specifying a variable reference within a “” string.
If you actually want to have the {} appear around the content you’d need
<?php
echo "{{$myVariable}}";
?>
Thanks guys. I realized that I won’t be able to do what I was hoping to do, but thanks for help.