Jump to content

Third tier quotes ?


Go to solution Solved by Sepodati,

Recommended Posts

This code works in PHP file OK.

<a href="http://www.example.com" target="_blank"><img src="http://www.example.com/demo.png" class="img-tipso" data-tipso-title="Tooltip title" data-tipso-content="<img src='http://www.example.com/demo2.png'/>

But if I place it inside PHP echo like this

<?php
//SET THE TIME ZONE
date_default_timezone_set('Europe/Vilnius');
//BEGIN
$today = strtotime(date("Y-m-d"));
$expireDate = strtotime("2017-12-31");
if ($today <= $expireDate) {
//ACTIVE
echo '<a href="http://www.example.com" target="_blank"><img src="http://www.example.com/demo.png" class="img-tipso" data-tipso-title="Tooltip title" data-tipso-content="<img src='http://www.example.com/demo2.png'/>';
} else {
//EXPIRED
echo '';
}
?>

I get the error 

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' 

 

Somebody told me that "I need three types of quotes"

Link to comment
https://forums.phpfreaks.com/topic/304862-third-tier-quotes/
Share on other sites

 

 

use double quotes for the image source

I tried that first thing. I get no PHP error but the script does not work then.

 

This does not work, does not get the second image loaded

<a href="http://www.example.com" target="_blank"><img src="http://www.example.com/demo.png" class="img-tipso" data-tipso-title="Tooltip title" data-tipso-content="<img src="http://www.example.com/demo2.png"/>
Link to comment
https://forums.phpfreaks.com/topic/304862-third-tier-quotes/#findComment-1550719
Share on other sites

I tried pasting you code the code above and still get the 

 

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'

 

You did not translate the whole code string. I use the https://github.com/object505/tipso I should have mentioned this above.

Edited by smile
Link to comment
https://forums.phpfreaks.com/topic/304862-third-tier-quotes/#findComment-1550767
Share on other sites

I don't know what you did but the examples I posted are syntactically correct for PHP (though they are missing the same closing quote on the attribute as yours was). Look at how they work and incorporate whichever one into your code. Don't just copy and paste.

Link to comment
https://forums.phpfreaks.com/topic/304862-third-tier-quotes/#findComment-1550769
Share on other sites

I'm having hard time to understand what is needed as my main language is not english, and I'm not a programmer.

I fixed the code like this. See attached image.

 

Now error is: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in 

post-62360-0-04758200-1504634582_thumb.png

Link to comment
https://forums.phpfreaks.com/topic/304862-third-tier-quotes/#findComment-1550789
Share on other sites

  • Solution

https://3v4l.org/VJoGS

 

echo '<a href="http://www.example.com" target="_blank"><img src="http://www.petmd.com/sites/all/modules/breedopedia/images/thumbnails/cat/tn-sokoke-forest-cat.jpg" class="img-tipso" data-tipso-title="Tooltip title" data-tipso-content="<img src=\'http://www.petmd.com/sites/all/modules/breedopedia/images/thumbnails/cat/tn-sokoke-forest-cat.jpg\'/>">';
Edited by Sepodati
Link to comment
https://forums.phpfreaks.com/topic/304862-third-tier-quotes/#findComment-1550800
Share on other sites

https://3v4l.org/VJoGS

 

echo '<a href="http://www.example.com" target="_blank"><img src="http://www.petmd.com/sites/all/modules/breedopedia/images/thumbnails/cat/tn-sokoke-forest-cat.jpg" class="img-tipso" data-tipso-title="Tooltip title" data-tipso-content="<img src=\'http://www.petmd.com/sites/all/modules/breedopedia/images/thumbnails/cat/tn-sokoke-forest-cat.jpg\'/>">';

 

Thank you, works perfect now. If only I could understand why  :shrug: I see some places changed

 

Instead of

png\'"/>';

you changed to

png\'/>">';
Link to comment
https://forums.phpfreaks.com/topic/304862-third-tier-quotes/#findComment-1550803
Share on other sites

In case the link goes down here is the code

echo '<a href="http://www.example.com" target="_blank"><img src="http://www.petmd.com/sites/all/modules/breedopedia/images/thumbnails/cat/tn-sokoke-forest-cat.jpg" class="img-tipso" data-tipso-title="Tooltip title" data-tipso-content="<img src=\'http://www.petmd.com/sites/all/modules/breedopedia/images/thumbnails/cat/tn-sokoke-forest-cat.jpg\'/>">';
Link to comment
https://forums.phpfreaks.com/topic/304862-third-tier-quotes/#findComment-1550810
Share on other sites

Thank you, works perfect now. If only I could understand why  :shrug: I see some places changed

If you ignore PHP for a second, and shorten things up, this is what you want:

<a href="e.com"><img src="cat.jpg" class="img-tipso" data-tipso-title="title" data-tipso-content="<img src='a.jpg'/>">

 

The two > symbols at the end each close one of the <img> tags. That's why you need two, one inside the double quotes and one to close the actual <img src="cat.jpg">.

 

Now to take that into PHP, as mentioned before, you just add escape characters before the single quotes if it's enclosed by single quotes.

 

echo '<a href="http://www.example.com"><img src="cat.jpg" class="img-tipso" data-tipso-title="title" data-tipso-content="<img src=\'a.jpg\'/>">';

Link to comment
https://forums.phpfreaks.com/topic/304862-third-tier-quotes/#findComment-1550819
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.