Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7686727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:32:42+00:00 2026-05-31T19:32:42+00:00

I am trying to play with php, I aint very good. But I figured

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:32:43+00:00Added an answer on May 31, 2026 at 7:32 pm

    You need to echo it so it is actually output.

    div class="<?php echo $shorttag; ?>"
    
    img src="/img/<?php echo $shorttag; ?>.jpg"
    

    If PHP is configured to use short_open_tag (which is not usually recommended since it may be turned off on some servers)

    img src="/img/<?= $shorttag ?>.jpg"
    

    The rules change for PHP 5.4 and later, where you can use <?= ?> without having to turn on short_open_tag:

    This directive also affected the shorthand <?= before PHP 5.4.0, which is identical to <? echo. Use of this shortcut required short_open_tag to be on. Since PHP 5.4.0, <?= is always available.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about PHP Class. I am trying to get the result
I'm trying to write a simple PHP MVC framework to play with. Right now,
iam trying play animation with xcode,in specefic Time for example after 3 minutes play
I am trying to play music in my application. The music works fine but
I started trying to play with Mono, mostly for fun at the moment. I
I am trying to play audio in a Java applet but it is not
Ok, I'm trying to play an HTML audio code on iPad but does not
PHP + javascript code + flv player: I am trying to play a .flv
I am trying to use http://code.google.com/p/amazon-s3-php-class/ to force-dowload files from AWS S3. I have
I have been trying this for so long, but was not able to implement

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.