Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP opening tags and XML declaration

Tags:

php

xml

phpstorm

I am new in PhpStorm and I run into a problem when declaring xml on .php file, The problem I am talking about is that PhpStorm is refers the <? ?> as the short opening tags as php opening tags while I set short_open_tag = Off at the php.ini.

How can I set PhpStorm so it won't refer the short php opening tags as php opening tags?

like image 503
Aviel Fedida Avatar asked Jul 23 '26 01:07

Aviel Fedida


2 Answers

PHPStorm as of now does not have any setting for that (see WI-2059 add "Disable short tags" option to project's options).

So you can not set that so far. All you can do is to write the code in a way that it does not clash, for example by echoing the XML declaration processing instruction:

<?php echo '<?xml version="1.0" encoding="utf-8" ?>' ?>
like image 67
hakre Avatar answered Jul 25 '26 17:07

hakre


Variables, echos. Meh. Why not simply...

<<?php ?>?xml version="1.0" encoding="utf-8" ?>

No mess, no complains from PHPStorm or whatever. Basically, you may even use just <??> instead of <?php ?>, if you don't need the absolutely bulletproof solution covering both on and off cases for short_open_tag.

like image 45
Alex Offshore Avatar answered Jul 25 '26 17:07

Alex Offshore