PHP variable will not store html tags in Sourcerer

This forum is for general questions about extensions for Joomla! 3.x.

Moderators: pe7er, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
vic+for+her
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Mar 15, 2020 7:03 am

PHP variable will not store html tags in Sourcerer

Post by vic+for+her » Tue Nov 29, 2022 7:47 am

I have been trying to set a php variable with some html code in it in an article and it gets stripped out as I have tested the length. A very simple example is:

$test = '<b>Some text</b>';
echo $test . strlen($test);

All I get back is Some text, not bolded, and with length of 9. I have searched in vain to find an answer but unsuccessful. I am sure there is a simple solution. Hopefully someone can help.
Last edited by toivo on Tue Nov 29, 2022 8:42 pm, edited 3 times in total.
Reason: mod note: moved from 3.x General Questions, retitled

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2902
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: PHP variable will not store html tags

Post by SharkyKZ » Tue Nov 29, 2022 7:56 am

Not reproducible. This need more context.

vic+for+her
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Mar 15, 2020 7:03 am

Re: PHP variable will not store html tags

Post by vic+for+her » Tue Nov 29, 2022 9:55 am

SharkyKZ wrote:
Tue Nov 29, 2022 7:56 am
Not reproducible. This need more context.
I have added to my original post - does this help?

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2902
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: PHP variable will not store html tags

Post by SharkyKZ » Tue Nov 29, 2022 9:59 am

Still not reproducible. strlen($test) returns 16 https://3v4l.org/c1q42.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44088
Joined: Sat Apr 05, 2008 9:58 pm

Re: PHP variable will not store html tags

Post by Webdongle » Tue Nov 29, 2022 10:42 am

When you 'inspect' the front end what do you see?
I see comment tags added to the code when placed in an Article.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".

vic+for+her
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Mar 15, 2020 7:03 am

Re: PHP variable will not store html tags

Post by vic+for+her » Tue Nov 29, 2022 11:16 am

I have provided more information which hopefully helps. Below is the code which I have inserted in an article:

{source} <?php
//
defined('_JEXEC') or die;
//
$item1Content = 'Test <b>string</b>';
echo 'Test string is: ' . $item1Content . ', Length is: ' . strlen($item1Content);
?>{/source}

How it appears is in the image. Note that the word string is not bolded, and length is 11.

We are using Joomla 3.9.28, RocketTheme Callisto template, and php 7.4.33.
Output.jpg
You do not have the required permissions to view the files attached to this post.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17435
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: PHP variable will not store html tags in Sourcerer

Post by toivo » Tue Nov 29, 2022 8:47 pm

Moved this topic to 3.x Extensions sub forum because of Sourcerer.

If you have a Pro subscription, post the issue to the Regular Labs support forum.
Toivo Talikka, Global Moderator

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 44088
Joined: Sat Apr 05, 2008 9:58 pm

Re: PHP variable will not store html tags in Sourcerer

Post by Webdongle » Tue Nov 29, 2022 9:18 pm

Tried with sorcerer
php 02.JPG
Tested with fresh Joomla with sample data default Protostar Template
You do not have the required permissions to view the files attached to this post.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"When I'm right no one remembers but when I'm wrong no one forgets".


Locked

Return to “Extensions for Joomla! 3.x”