How to print IMG tag... xhtml sytlee

Posted on 2005-05-02
Last Modified: 2006-11-18
Hello all EEs... I have a PHP quickie.

I am trying to dynamically write some IMG stars within a PHP for loop,
however they need to be XHTML compliant - WITH a closing slash, like so:

$star="<img src='images/star.gif' height='12px' width='12px' alt='someALT' />";
(... the above will not output the closing slash)

How can I ensure that the backslash is present within the generated IMG tags?

Thanks muchly as time is of the essence (& my eyes hurt)

Question by:ARCglide
    LVL 20

    Accepted Solution

    the closing slash shows when i echo that line in php (php 5.0.4)

    $star="<img src='images/star.gif' height='12px' width='12px' alt='someALT' />";
    echo $star;

    and it's there.  are you using HTMLtidy or something like it to redo your tags?
    LVL 4

    Author Comment

    I am using Firefox v1.0.3... and viewing:

    When I select some of the stars (eg. row5) - right click - 'view selected source' all the IMG and BR closing slashes are omitted!
    However, when viewing full-page-source they are all present and correct.

    Cool - all is proved good... thanX

    LVL 20

    Expert Comment

    I think that's a property of the parser in FireFox.
    LVL 4

    Author Comment

    Not a huge issue - but seriously annoying when at the end of a bank-holiday weekend 'code-burn' the little things seemed to be going screwy.

    You we're right - so you get the points!

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now