BUG: PHP tag inside script tag won't be beautiful as normal

Post your questions and problem reports here

Moderator: kfury77

Forum rules
Please try to follow these guidelines. This will help to receive faster and more accurate response.
  • Check the Support section of the corresponding product first. Chances are you will find your answer there;
  • Do not create new topics for already reported problems. Add your comments to the existing topics instead;
  • Create separate topic for each problem request. Do NOT post a number of non-related problem reports in a single topic;
  • Give your topic a meaningful title. Titles such as "A question," "Bug report" and "Help!" provide others no clue what your message is about;
  • Include the version number of the software you are using;
  • This is not an official customer support helpdesk. If you need a prompt and official response, please contact our support team directly instead. It may take a while until you receive a reply in the forum;
Post Reply
lwmirkk
Posts: 3
Joined: Wed Jan 04, 2023 7:00 pm

BUG: PHP tag inside script tag won't be beautiful as normal

Post by lwmirkk »

Example:

Code: Select all

<script type="text/javascript">window.history.pushState({},"","/path/<?php echo $something;?>");</script>
The variable is detected, but the code is not beautiful as expected.
lwmirkk
Posts: 3
Joined: Wed Jan 04, 2023 7:00 pm

Re: BUG: PHP tag inside script tag won't be beautiful as nor

Post by lwmirkk »

Same thing happen if PHP tag is inside CSS code.
But in this case, the PHP code is recognized as CSS class name.
stetsonfiction
Posts: 1
Joined: Wed Jul 12, 2023 6:05 am

Re: BUG: PHP tag inside script tag won't be beautiful as nor

Post by stetsonfiction »

Is it intended to support the CakePHP PHP Framework?
Cake is my favorite, and I use it almost exclusively.
spawnerjeer
Posts: 1
Joined: Mon Apr 01, 2024 4:54 am
Contact:

Re: BUG: PHP tag inside script tag won't be beautiful as nor

Post by spawnerjeer »

The same outcome occurs if a PHP element is inserted into CSS.
kevincalori
Posts: 2
Joined: Tue Aug 06, 2024 4:15 pm
Location: USA

Re: BUG: PHP tag inside script tag won't be beautiful as nor

Post by kevincalori »

If your code editor struggles to format PHP within a <script> tag, try separating the PHP from the JavaScript to improve readability. For example, assign the PHP output to a JavaScript variable before using it in your script. This can make the code easier to manage and might help your editor format it better.
KarlKirby
Posts: 1
Joined: Fri Jun 21, 2024 9:39 am
Contact:

Re: BUG: PHP tag inside script tag won't be beautiful as nor

Post by KarlKirby »

When PHP code is embedded in JavaScript (inside a <script> tag), linters may not handle the mixed syntax well. This is because PHP and JavaScript have different rules and syntax, and many formatters don't process hybrid structures effectively.
Post Reply