PHP syntax

Posted on 2012-09-19
Last Modified: 2012-09-19
I am having a syntax issue that I cannot figure out. Here is the code being executed:
	<?= $this->Html->link(
			$this->Html->url('/img/blog_widget/img.png' . " " . __("This is my html", true)),
				'alt' => __("alt text here", true),
				'target' => '_blank'
		array('escape' => false)

Open in new window

Here is the output. As you can see, the img tag is not closing and the HTML that is supposed to be echoed is included in the img reference.

<a href=""><img src="/img/blog_widget/img.png This is my html" alt="alt text here" target="_blank" /></a>

Any idea why this is happening?
Question by:lvollmer
    LVL 107

    Expert Comment

    by:Ray Paseur
    It looks like an error in the code that generates the HTML  Can you please post that code?

    Or maybe just change line 3 to this:

    $this->Html->url('/img/blog_widget/img.png' . ">" . __("This is my html", true)),

    Author Comment

    Thanks - that spits out &gt; instead of the closing bracket.

    It's cake 1.2. I will try to find a link.
    LVL 42

    Accepted Solution

    Don't really know cake, but it looks like a concatenation problem. shouldn't it be like this, i.e create the image and then concatenate 'This is my HTML'

         		array('alt' => __("alt text here", true), 'target' => '_blank')
    		) . __("This is my html", true),
         array('escape' => false)

    Open in new window


    Author Closing Comment

    Yes! Thank you.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 Mobile App Development with PhoneGap

    PhoneGap can help you leverage your already existing HTML5, JavaScript, and CSS skills in order to create and deploy cross-platform mobile apps.This program comprehensively covers HTML5 mobile app development from top to bottom.

    Suggested Solutions

    I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
    Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
    This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
    The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

    761 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

    15 Experts available now in Live!

    Get 1:1 Help Now