3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = '{ifvar[?]}<tr> <td class="padding-left20 padding-right20" style="padding: 5px 40px 0 40px; background-color: #f8f8f8;"> <span class="size24" style="display: block; font-size: 24px; color: #472786; font-weight: bold; line-height: 1;"> Enjoy our internal messaging system </span> <span class="size14" style="display: block;"> What does it give you? A Casting Professional who is looking to find talent for their projects with AllCasting.com, can initiate a conversation with our members through our easy to use Messaging System. If there\'s a casting call in your area that perfectly matches your profile, you\'ll get notified as well! </span> <span class="size14" style="display: block; padding: 10px 0 0 0;"> You have <span style="font-style: italic; color: #472786; font-weight: bold;"> ? UNREAD message{plural[{GES_UNREAD_CONVERSATIONS}]}s{/plural}</span> from agents and casting directors! </span> <span style="display: block; max-width: 210px; padding: 30px 0 0 0;" class="btnFullWidth size14"> <span class="desktop-btn" style="display: block; text-align: center; padding: 10px 18px 9px 18px; background-color: #2bb672; border-radius: 5px 5px 5px 5px;"> <a href="{GES_SINGLE_LOGIN_URL}&goto=/messages" style="display: block; text-align: center; text-decoration: none; vertical-align: middle; text-transform: uppercase;"> <span style="display: block; font-size: 14px; font-weight: bold; color: #ffffff; line-height: 1.4;">view all messages</span> </a> </span> </span> </td> </tr> <tr> <td style="padding:0;"> <span style="display: block; height: 0; padding: 10px 0 0 0;">&nbsp;</span> </td> </tr> {/ifvar}'; /* echo '<pre style="color:green">'; echo htmlentities($text); echo '</pre>'; */ echo '<pre style="color:red">'; echo htmlentities(_replaceIfVarTags($text)); echo '</pre>'; function _replaceIfVarTags($text) { // $text = iconv("UTF-8", "UTF-8//IGNORE", $text); $regexp = '/\\{!?ifvar\\[(.*?)(?=\\]})\\]\\}(([\\s\\S](?!\\{!?ifvar))*?)\\{\\/ifvar\\}/i'; preg_match_all($regexp, $text, $matches); echo '<hr><pre style="color:black">'; echo htmlentities(print_r($matches,1)); echo '</pre><hr>'; if (!$matches || !$matches[0]) return $text; foreach ($matches[0] as $k => $v) { $value = trim($matches[1][$k]); if (strpos($v, '{!ifvar') === false) { if (in_array($value, ['', '0', 0, false, 'false', null], true)) { $text = str_replace($v, '', $text); } else { $text = str_replace($v, $matches[2][$k], $text); } } else { if ($value === '') { $text = str_replace($v, $matches[2][$k], $text); } else { $text = str_replace($v, '', $text); } } } //return _replaceIfVarTags($text); }
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.4, 8.3.6 - 8.3.7
<pre style="color:red"><hr><pre style="color:black">Array ( [0] =&gt; Array ( [0] =&gt; {ifvar[?]}&lt;tr&gt; &lt;td class=&quot;padding-left20 padding-right20&quot; style=&quot;padding: 5px 40px 0 40px; background-color: #f8f8f8;&quot;&gt; &lt;span class=&quot;size24&quot; style=&quot;display: block; font-size: 24px; color: #472786; font-weight: bold; line-height: 1;&quot;&gt; Enjoy our internal messaging system &lt;/span&gt; &lt;span class=&quot;size14&quot; style=&quot;display: block;&quot;&gt; What does it give you? A Casting Professional who is looking to find talent for their projects with AllCasting.com, can initiate a conversation with our members through our easy to use Messaging System. If there&#039;s a casting call in your area that perfectly matches your profile, you&#039;ll get notified as well! &lt;/span&gt; &lt;span class=&quot;size14&quot; style=&quot;display: block; padding: 10px 0 0 0;&quot;&gt; You have &lt;span style=&quot;font-style: italic; color: #472786; font-weight: bold;&quot;&gt; ? UNREAD message{plural[{GES_UNREAD_CONVERSATIONS}]}s{/plural}&lt;/span&gt; from agents and casting directors! &lt;/span&gt; &lt;span style=&quot;display: block; max-width: 210px; padding: 30px 0 0 0;&quot; class=&quot;btnFullWidth size14&quot;&gt; &lt;span class=&quot;desktop-btn&quot; style=&quot;display: block; text-align: center; padding: 10px 18px 9px 18px; background-color: #2bb672; border-radius: 5px 5px 5px 5px;&quot;&gt; &lt;a href=&quot;{GES_SINGLE_LOGIN_URL}&amp;goto=/messages&quot; style=&quot;display: block; text-align: center; text-decoration: none; vertical-align: middle; text-transform: uppercase;&quot;&gt; &lt;span style=&quot;display: block; font-size: 14px; font-weight: bold; color: #ffffff; line-height: 1.4;&quot;&gt;view all messages&lt;/span&gt; &lt;/a&gt; &lt;/span&gt; &lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style=&quot;padding:0;&quot;&gt; &lt;span style=&quot;display: block; height: 0; padding: 10px 0 0 0;&quot;&gt;&amp;nbsp;&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; {/ifvar} ) [1] =&gt; Array ( [0] =&gt; ? ) [2] =&gt; Array ( [0] =&gt; &lt;tr&gt; &lt;td class=&quot;padding-left20 padding-right20&quot; style=&quot;padding: 5px 40px 0 40px; background-color: #f8f8f8;&quot;&gt; &lt;span class=&quot;size24&quot; style=&quot;display: block; font-size: 24px; color: #472786; font-weight: bold; line-height: 1;&quot;&gt; Enjoy our internal messaging system &lt;/span&gt; &lt;span class=&quot;size14&quot; style=&quot;display: block;&quot;&gt; What does it give you? A Casting Professional who is looking to find talent for their projects with AllCasting.com, can initiate a conversation with our members through our easy to use Messaging System. If there&#039;s a casting call in your area that perfectly matches your profile, you&#039;ll get notified as well! &lt;/span&gt; &lt;span class=&quot;size14&quot; style=&quot;display: block; padding: 10px 0 0 0;&quot;&gt; You have &lt;span style=&quot;font-style: italic; color: #472786; font-weight: bold;&quot;&gt; ? UNREAD message{plural[{GES_UNREAD_CONVERSATIONS}]}s{/plural}&lt;/span&gt; from agents and casting directors! &lt;/span&gt; &lt;span style=&quot;display: block; max-width: 210px; padding: 30px 0 0 0;&quot; class=&quot;btnFullWidth size14&quot;&gt; &lt;span class=&quot;desktop-btn&quot; style=&quot;display: block; text-align: center; padding: 10px 18px 9px 18px; background-color: #2bb672; border-radius: 5px 5px 5px 5px;&quot;&gt; &lt;a href=&quot;{GES_SINGLE_LOGIN_URL}&amp;goto=/messages&quot; style=&quot;display: block; text-align: center; text-decoration: none; vertical-align: middle; text-transform: uppercase;&quot;&gt; &lt;span style=&quot;display: block; font-size: 14px; font-weight: bold; color: #ffffff; line-height: 1.4;&quot;&gt;view all messages&lt;/span&gt; &lt;/a&gt; &lt;/span&gt; &lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style=&quot;padding:0;&quot;&gt; &lt;span style=&quot;display: block; height: 0; padding: 10px 0 0 0;&quot;&gt;&amp;nbsp;&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; ) [3] =&gt; Array ( [0] =&gt; ) ) </pre><hr> Deprecated: htmlentities(): Passing null to parameter #1 ($string) of type string is deprecated in /in/h3S5N on line 45 </pre>
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 <pre style="color:red"><hr><pre style="color:black">Array ( [0] =&gt; Array ( [0] =&gt; {ifvar[?]}&lt;tr&gt; &lt;td class=&quot;padding-left20 padding-right20&quot; style=&quot;padding: 5px 40px 0 40px; background-color: #f8f8f8;&quot;&gt; &lt;span class=&quot;size24&quot; style=&quot;display: block; font-size: 24px; color: #472786; font-weight: bold; line-height: 1;&quot;&gt; Enjoy our internal messaging system &lt;/span&gt; &lt;span class=&quot;size14&quot; style=&quot;display: block;&quot;&gt; What does it give you? A Casting Professional who is looking to find talent for their projects with AllCasting.com, can initiate a conversation with our members through our easy to use Messaging System. If there&#039;s a casting call in your area that perfectly matches your profile, you&#039;ll get notified as well! &lt;/span&gt; &lt;span class=&quot;size14&quot; style=&quot;display: block; padding: 10px 0 0 0;&quot;&gt; You have &lt;span style=&quot;font-style: italic; color: #472786; font-weight: bold;&quot;&gt; ? UNREAD message{plural[{GES_UNREAD_CONVERSATIONS}]}s{/plural}&lt;/span&gt; from agents and casting directors! &lt;/span&gt; &lt;span style=&quot;display: block; max-width: 210px; padding: 30px 0 0 0;&quot; class=&quot;btnFullWidth size14&quot;&gt; &lt;span class=&quot;desktop-btn&quot; style=&quot;display: block; text-align: center; padding: 10px 18px 9px 18px; background-color: #2bb672; border-radius: 5px 5px 5px 5px;&quot;&gt; &lt;a href=&quot;{GES_SINGLE_LOGIN_URL}&amp;goto=/messages&quot; style=&quot;display: block; text-align: center; text-decoration: none; vertical-align: middle; text-transform: uppercase;&quot;&gt; &lt;span style=&quot;display: block; font-size: 14px; font-weight: bold; color: #ffffff; line-height: 1.4;&quot;&gt;view all messages&lt;/span&gt; &lt;/a&gt; &lt;/span&gt; &lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style=&quot;padding:0;&quot;&gt; &lt;span style=&quot;display: block; height: 0; padding: 10px 0 0 0;&quot;&gt;&amp;nbsp;&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; {/ifvar} ) [1] =&gt; Array ( [0] =&gt; ? ) [2] =&gt; Array ( [0] =&gt; &lt;tr&gt; &lt;td class=&quot;padding-left20 padding-right20&quot; style=&quot;padding: 5px 40px 0 40px; background-color: #f8f8f8;&quot;&gt; &lt;span class=&quot;size24&quot; style=&quot;display: block; font-size: 24px; color: #472786; font-weight: bold; line-height: 1;&quot;&gt; Enjoy our internal messaging system &lt;/span&gt; &lt;span class=&quot;size14&quot; style=&quot;display: block;&quot;&gt; What does it give you? A Casting Professional who is looking to find talent for their projects with AllCasting.com, can initiate a conversation with our members through our easy to use Messaging System. If there&#039;s a casting call in your area that perfectly matches your profile, you&#039;ll get notified as well! &lt;/span&gt; &lt;span class=&quot;size14&quot; style=&quot;display: block; padding: 10px 0 0 0;&quot;&gt; You have &lt;span style=&quot;font-style: italic; color: #472786; font-weight: bold;&quot;&gt; ? UNREAD message{plural[{GES_UNREAD_CONVERSATIONS}]}s{/plural}&lt;/span&gt; from agents and casting directors! &lt;/span&gt; &lt;span style=&quot;display: block; max-width: 210px; padding: 30px 0 0 0;&quot; class=&quot;btnFullWidth size14&quot;&gt; &lt;span class=&quot;desktop-btn&quot; style=&quot;display: block; text-align: center; padding: 10px 18px 9px 18px; background-color: #2bb672; border-radius: 5px 5px 5px 5px;&quot;&gt; &lt;a href=&quot;{GES_SINGLE_LOGIN_URL}&amp;goto=/messages&quot; style=&quot;display: block; text-align: center; text-decoration: none; vertical-align: middle; text-transform: uppercase;&quot;&gt; &lt;span style=&quot;display: block; font-size: 14px; font-weight: bold; color: #ffffff; line-height: 1.4;&quot;&gt;view all messages&lt;/span&gt; &lt;/a&gt; &lt;/span&gt; &lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style=&quot;padding:0;&quot;&gt; &lt;span style=&quot;display: block; height: 0; padding: 10px 0 0 0;&quot;&gt;&amp;nbsp;&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; ) [3] =&gt; Array ( [0] =&gt; ) ) </pre><hr> Deprecated: htmlentities(): Passing null to parameter #1 ($string) of type string is deprecated in /in/h3S5N on line 45 </pre>
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.30, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
<pre style="color:red"><hr><pre style="color:black">Array ( [0] =&gt; Array ( [0] =&gt; {ifvar[?]}&lt;tr&gt; &lt;td class=&quot;padding-left20 padding-right20&quot; style=&quot;padding: 5px 40px 0 40px; background-color: #f8f8f8;&quot;&gt; &lt;span class=&quot;size24&quot; style=&quot;display: block; font-size: 24px; color: #472786; font-weight: bold; line-height: 1;&quot;&gt; Enjoy our internal messaging system &lt;/span&gt; &lt;span class=&quot;size14&quot; style=&quot;display: block;&quot;&gt; What does it give you? A Casting Professional who is looking to find talent for their projects with AllCasting.com, can initiate a conversation with our members through our easy to use Messaging System. If there's a casting call in your area that perfectly matches your profile, you'll get notified as well! &lt;/span&gt; &lt;span class=&quot;size14&quot; style=&quot;display: block; padding: 10px 0 0 0;&quot;&gt; You have &lt;span style=&quot;font-style: italic; color: #472786; font-weight: bold;&quot;&gt; ? UNREAD message{plural[{GES_UNREAD_CONVERSATIONS}]}s{/plural}&lt;/span&gt; from agents and casting directors! &lt;/span&gt; &lt;span style=&quot;display: block; max-width: 210px; padding: 30px 0 0 0;&quot; class=&quot;btnFullWidth size14&quot;&gt; &lt;span class=&quot;desktop-btn&quot; style=&quot;display: block; text-align: center; padding: 10px 18px 9px 18px; background-color: #2bb672; border-radius: 5px 5px 5px 5px;&quot;&gt; &lt;a href=&quot;{GES_SINGLE_LOGIN_URL}&amp;goto=/messages&quot; style=&quot;display: block; text-align: center; text-decoration: none; vertical-align: middle; text-transform: uppercase;&quot;&gt; &lt;span style=&quot;display: block; font-size: 14px; font-weight: bold; color: #ffffff; line-height: 1.4;&quot;&gt;view all messages&lt;/span&gt; &lt;/a&gt; &lt;/span&gt; &lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style=&quot;padding:0;&quot;&gt; &lt;span style=&quot;display: block; height: 0; padding: 10px 0 0 0;&quot;&gt;&amp;nbsp;&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; {/ifvar} ) [1] =&gt; Array ( [0] =&gt; ? ) [2] =&gt; Array ( [0] =&gt; &lt;tr&gt; &lt;td class=&quot;padding-left20 padding-right20&quot; style=&quot;padding: 5px 40px 0 40px; background-color: #f8f8f8;&quot;&gt; &lt;span class=&quot;size24&quot; style=&quot;display: block; font-size: 24px; color: #472786; font-weight: bold; line-height: 1;&quot;&gt; Enjoy our internal messaging system &lt;/span&gt; &lt;span class=&quot;size14&quot; style=&quot;display: block;&quot;&gt; What does it give you? A Casting Professional who is looking to find talent for their projects with AllCasting.com, can initiate a conversation with our members through our easy to use Messaging System. If there's a casting call in your area that perfectly matches your profile, you'll get notified as well! &lt;/span&gt; &lt;span class=&quot;size14&quot; style=&quot;display: block; padding: 10px 0 0 0;&quot;&gt; You have &lt;span style=&quot;font-style: italic; color: #472786; font-weight: bold;&quot;&gt; ? UNREAD message{plural[{GES_UNREAD_CONVERSATIONS}]}s{/plural}&lt;/span&gt; from agents and casting directors! &lt;/span&gt; &lt;span style=&quot;display: block; max-width: 210px; padding: 30px 0 0 0;&quot; class=&quot;btnFullWidth size14&quot;&gt; &lt;span class=&quot;desktop-btn&quot; style=&quot;display: block; text-align: center; padding: 10px 18px 9px 18px; background-color: #2bb672; border-radius: 5px 5px 5px 5px;&quot;&gt; &lt;a href=&quot;{GES_SINGLE_LOGIN_URL}&amp;goto=/messages&quot; style=&quot;display: block; text-align: center; text-decoration: none; vertical-align: middle; text-transform: uppercase;&quot;&gt; &lt;span style=&quot;display: block; font-size: 14px; font-weight: bold; color: #ffffff; line-height: 1.4;&quot;&gt;view all messages&lt;/span&gt; &lt;/a&gt; &lt;/span&gt; &lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style=&quot;padding:0;&quot;&gt; &lt;span style=&quot;display: block; height: 0; padding: 10px 0 0 0;&quot;&gt;&amp;nbsp;&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; ) [3] =&gt; Array ( [0] =&gt; ) ) </pre><hr></pre>
Output for 7.0.0 - 7.0.29, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33
<pre style="color:red"><hr><pre style="color:black">Array ( [0] =&gt; Array ( ) [1] =&gt; Array ( ) [2] =&gt; Array ( ) [3] =&gt; Array ( ) ) </pre><hr>{ifvar[?]}&lt;tr&gt; &lt;td class=&quot;padding-left20 padding-right20&quot; style=&quot;padding: 5px 40px 0 40px; background-color: #f8f8f8;&quot;&gt; &lt;span class=&quot;size24&quot; style=&quot;display: block; font-size: 24px; color: #472786; font-weight: bold; line-height: 1;&quot;&gt; Enjoy our internal messaging system &lt;/span&gt; &lt;span class=&quot;size14&quot; style=&quot;display: block;&quot;&gt; What does it give you? A Casting Professional who is looking to find talent for their projects with AllCasting.com, can initiate a conversation with our members through our easy to use Messaging System. If there's a casting call in your area that perfectly matches your profile, you'll get notified as well! &lt;/span&gt; &lt;span class=&quot;size14&quot; style=&quot;display: block; padding: 10px 0 0 0;&quot;&gt; You have &lt;span style=&quot;font-style: italic; color: #472786; font-weight: bold;&quot;&gt; ? UNREAD message{plural[{GES_UNREAD_CONVERSATIONS}]}s{/plural}&lt;/span&gt; from agents and casting directors! &lt;/span&gt; &lt;span style=&quot;display: block; max-width: 210px; padding: 30px 0 0 0;&quot; class=&quot;btnFullWidth size14&quot;&gt; &lt;span class=&quot;desktop-btn&quot; style=&quot;display: block; text-align: center; padding: 10px 18px 9px 18px; background-color: #2bb672; border-radius: 5px 5px 5px 5px;&quot;&gt; &lt;a href=&quot;{GES_SINGLE_LOGIN_URL}&amp;goto=/messages&quot; style=&quot;display: block; text-align: center; text-decoration: none; vertical-align: middle; text-transform: uppercase;&quot;&gt; &lt;span style=&quot;display: block; font-size: 14px; font-weight: bold; color: #ffffff; line-height: 1.4;&quot;&gt;view all messages&lt;/span&gt; &lt;/a&gt; &lt;/span&gt; &lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td style=&quot;padding:0;&quot;&gt; &lt;span style=&quot;display: block; height: 0; padding: 10px 0 0 0;&quot;&gt;&amp;nbsp;&lt;/span&gt; &lt;/td&gt; &lt;/tr&gt; {/ifvar}</pre>
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/h3S5N on line 64
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/h3S5N on line 64
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/h3S5N on line 64
Process exited with code 255.

preferences:
217.37 ms | 401 KiB | 389 Q