[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

PHP syntax

Posted on 2012-09-19
4
Medium Priority
?
439 Views
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->image(
			$this->Html->url('/img/blog_widget/img.png' . " " . __("This is my html", true)),
			array(
				'alt' => __("alt text here", true),
				'target' => '_blank'
			)
		),
		$this->Html->url(
			'http://www.google.com'
		),
		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="http://www.google.com"><img src="/img/blog_widget/img.png This is my html" alt="alt text here" target="_blank" /></a>

Any idea why this is happening?
0
Comment
Question by:lvollmer
  • 2
4 Comments
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 38414466
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)),
0
 

Author Comment

by:lvollmer
ID: 38414484
Thanks - that spits out &gt; instead of the closing bracket.

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

Accepted Solution

by:
Chris Stanyon earned 2000 total points
ID: 38414534
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'

$this->Html->link(
     $this->Html->image(
     	$this->Html->url('/img/blog_widget/img.png'),
     		array('alt' => __("alt text here", true), 'target' => '_blank')
		) . __("This is my html", true),
     
     $this->Html->url('http://www.google.com'),

     array('escape' => false)
)

Open in new window

0
 

Author Closing Comment

by:lvollmer
ID: 38414563
Yes! Thank you.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

872 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