Batch Script to Replace PHP Short Open Tags with <Php

How do i convert php short tag to full one

Converting can be written using http://php.net/manual/en/function.token-get-all.php . Unlike find&replace, this does not affect XML declarations and so on.
Converting vs. enabling ST: It depends. Many programmers probably prefers <?php to <?, so when you convert, you code will be more "standard". However, the importancy https://meta.stackoverflow.com/of "standard"-way depends on the situation.

How do i convert php short tag to full one

Converting can be written using http://php.net/manual/en/function.token-get-all.php . Unlike find&replace, this does not affect XML declarations and so on.
Converting vs. enabling ST: It depends. Many programmers probably prefers <?php to <?, so when you convert, you code will be more "standard". However, the importancy https://meta.stackoverflow.com/of "standard"-way depends on the situation.

Finding all PHP short tags

The best way to find short-tags in vim is to find all occurrences of <? not followed by a p:

/<?[^p]

The reason your regex is failing in vim is because /? finds literal question marks, while \? is a quantifier; /<\? in vim will attempt to find 0 or 1 less-than signs. This is backwards from what you might expect in most regular expression engines.


If you want to match short tags that are immediately followed by a new line, you cannot use [^p], which requires there to be something there to match which isn't a p. In this case, you can match "not p or end-of-line" with

/<?\($\|[^p]\)

XAMPP does not recognize php, must replace all ? with ?php

You'll have to enable short_open_tag in php.ini

However, for compatibility reasons with system where you haven't control over the php.ini, I would not use the short open tags.

Is there possible we use ? to ?php

You need to update php.ini to accept the short notation of php's syntax. Look in php.ini and look for short_open_tag and set to On. After you are done save it and restart Apache or Nginx (whichever you use).

PHP - What's wrong on this PHP syntax?

The code looks okay. However, your code is very difficult to read - I can almost understand dreamweaver for choking on it :)

Here is a simpler suggestion:

for($i=1; $i<=$npagine; $i++)
{
$class = ($i == $index ? "paginas" : "pagine");
echo "<a class='$class' href='index.php?$splitter_zone&index=$i'>$i</a>";
}

nginx + php-fpm not escaping with ? but IS escaping with ?php

Change your php configuration file to accept short tags. Reference



Related Topics



Leave a reply



Submit