So within administrator function.
echo("<script>console.log('PHP: " . $data . "');</script>");
It seems it doesn't insert the js script on the page. This works from a simple PHP file, but not from Joomla. Any ideas?
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.Visit Stack Exchange
Joomla Stack Exchange is a question and answer site for Joomla! administrators, users, developers and designers. It only takes a minute to sign up.Sign up to join this community
You can use Joomla's Web Asset Manager to insert inline scripts via PHP, like so:
use Joomla\CMS\Factory; $wa = Factory::getApplication()->getDocument()->getWebAssetManager(); $wa->addInlineScript('console.log("PHP: ' . $data . '")');