I am trying to play with php, I aint very good. But I figured its about time I started playing with it
What I have is say a page called ascr
Its filename is acsr.php
I have created a global php include, so I can play with different vars and include them dynamically.
So I have made a var called $shorttag = “acsr”;
On my page I would like to use that shorttag to fire images and classes etc.
So for an image I want to display
img src="/img/<?php $shorttag; ?>.jpg"
and in other places perhaps,
div class="<?php $shorttag; ?>"
Is this the CORRECT way of doing stuff like this ?
//////////////////////////////////////
Example.
say I have folder with image in it called acsr.jpg
On my dynamic page I want to echo that image, but instead of using filename, I want to pull it in based on my php var , in this case its called $shorttag so essentially, $shorttag=acsr , and therefore I can spew out something like:
<?php $shorttag; ?>.jpg
( code above more than likely wrong )
But the result gives me ascr.jpg
You need to
echoit so it is actually output.If PHP is configured to use
short_open_tag(which is not usually recommended since it may be turned off on some servers)The rules change for PHP 5.4 and later, where you can use
<?= ?>without having to turn onshort_open_tag: