3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /* Copyright © 2014, Anthony Jordan (Magictallguy) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by Magictallguy. Neither the name of Magictallguy nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY ANTHONY JORDAN (MAGICTALLGUY) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANTHONY JORDAN (MAGICTALLGUY) BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ function emote($source) { $emotes = array( '/(\:\))|(\:\=\))|(\:\-\))/' => 'smile', '/(\:\()|(\:\=\()|(\:\-\()/' => 'sadsmile', '/(\:D)|(\:\=D)|(\:\-D)/i' => 'bigsmile', '/(8\))|(8\=\))|(8\-\))|(B\))|(B\=\))|(B\-\))|(\(cool\))' => 'cool', '/(\:o)|(\:\=o)|(\:\-o)/i' => 'wink', '/(\;\()|(\;\-\()|(\;\=\()/' => 'crying', '/(\(sweat\))|(\(\:\|)/i' => 'sweating', '/(\:\|)|(\:\=\|)|(\:\-\|)/' => 'speechless', '/(\:\*)|(\:\=\*)|(\:\-\*)/' => 'kiss', '/:P:=P:-P/i' => 'tongueout', '(\(blush\))|(\:\$)|(\:\-\$)|(\:\=\$)|(\:\"\>)/i' => 'blush', '/(\:\^\))/' => 'wondering', '/(\|\-\))|(\I\-\))|(\I\=\))|(\(snooze\))/i' => 'sleepy', '/(\|\()|(\|\-\()|(\|\=\()/' => 'dull', '/(\(inlove\)/i' => 'inlove', '/(\]\:\))|(>\:\))|(\(grin\))/i' => 'evilgrin', '/(\(talk\))/i' => 'talking', '/(\(yawn\))|(\|\-\(\))/i' => 'yawn', '/(\(puke\))|(\:\&)|(\:\-\&)|(\:\=\&)/i' => 'puke', '/(\(doh\))/i' => 'doh', '/(\:\@)|(\:\-\@)|(\:\=\@)|(\x\()|(\x\-\()|(\x\=\()/i' => 'angry', '/(\(wasntme\))/i' => 'wasntme', '/(\(party\))/i' => 'party', '/(\:S)|(\:\-S)|(\:\=S)/i' => 'worried', '/(\(mm\))|(\(mmm\))/i' => 'mmm', '/(8\-\|)|(B\-\|)|(8\|)|(B\|)|(8\=\|)|(B\=\|)|(\(nerd\))/i' => 'nerd', '/(\:x)|(\:\-x)|(\:\=x)|(\:\#)|(\:\-\#)|(\:\=\#)/i' => 'lipssealed', '/(\(hi\))/i' => 'hi', '/(\(call\))/i' => 'call', '/(\(devil\))/i' => 'devil', '/(\(angel\))/i' => 'angel', '/(\(envy\))/i' => 'envy', '/(\(wait\))/i' => 'wait', '/(\(bear\))|(\(hug\))/i' => 'bear', '/(\(makeup\))|(\(kate\))/i' => 'makeup', '/(\(giggle\))|(\(chuckle\))/i' => 'coveredlaugh', '/(\(clap\))|(\(applaud\))|(\(applause\))/i' => 'clapping', '/(\(think\))|(\:\?)|(\:\-\?)|(\:\=\?)/i' => 'thinking', '/(\(bow\)/i' => 'bow', '/(rofl)|(\(rofl\))/i' => 'rofl', '/(\(whew\))|(\(phew\))/i' => 'whew', '/(\(happy\))/i' => 'happy', '/(\(smirk\))/i' => 'smirking', '/(\(nod\))/i' => 'nodding', '/(\(shake\))/i' => 'shaking', '/(\(punch\))/i' => 'punch', '/(\(emo\))/i' => 'emo', '/(\(y\))|(\(ok\))/i' => 'yes', '/(\(n\)))/i' => 'no', '/(\(handshake\))/i' => 'handshake', '/(\(skype\))|(\(ss\))/i' => 'skype', '/(\(h\))|(\(l\))/i' => 'heart', '/(\(u\))/i' => 'brokenheart', '/(\(e\))|(\(m\))/i' => 'mail', '/(\(f\))/i' => 'flower', '/(\(rain\))|(\(london\))|(\(st\))/i' => 'rain', '/(\(sun\))/i' => 'sun', '/(\(o\))|(\(time\))|(\(clock\))/i' => 'clock', '/(\(8\))|(\(music\))/i' => 'music', '/(\(\~\))|(\(film\))|(\(movie\))/i' => 'movie', '/(\(mp\))|(\(ph\))|(\(phone\))|(\(mobile\))|(\(cell\))/i' => 'phone', '/(\(coffee\))/i' => 'coffee', '/(\(pizza\))|(\(pi\))|(\(za\))/i' => 'pizza', '/(\(cash\))|(\(mo\))|(\(\$\))/i' => 'cash', '/(\(muscle\))|(\(flex\))/i' => 'muscle', '/(\(\^\))|(\(cake\))/i' => 'cake', '/(\(beer\))/i' => 'beer', '/(\(d\))/i' => 'drink', '/(\(dance\))|(\\\o\/)|(\\\:D\/)/i' => 'dance', '/(\(ninja\))/i' => 'ninja', '/(\(\*\))|(\(star\))/i' => 'star', '/(\(mooning\))/i' => 'mooning', '/(\(finger\))/i' => 'finger', '/(\(smoking\))|(\(smoke\))|(\(ci\))|(\(cig\))/i' => 'smoking', '/(\(drunk\))/i' => 'drunk', '/(\(bandit\))/i' => 'bandit', '/(\(toivo\))/i' => 'toivo', '/(\(rock\))/i' => 'rock', '/(\(headbang\))|(\(banghead\))/i' => 'headbang', '/(\(bug\))/i' => 'bug', '/(\(fubar\))/i' => 'fubar', '/(\(poolparty\))/i' => 'poolparty', '/(\(swear\))/i' => 'swear', '/(\(tmi\))/i' => 'tmi', '/(\(heidy\))/i' => 'heidy', '/(\(malthe\))/i' => 'malthe', '/(\(tauri\))/i' => 'tauri', '/(\(priidu\))/i' => 'priidu' ); foreach($emotes as $command => $image) $source = preg_replace($command, '[emote]images/smilies/skype/'.$image.'.gif[/emote]', $source); return $source; } function show_emoticons() { $emotes = array( ':)' => 'smile', ':(' => 'sadsmile', ':D' => 'bigsmile', '8)' => 'cool', ':O' => 'wink', ';(' => 'crying', '(sweat)' => 'sweating', ':|' => 'speechless', ':*' => 'kiss', ':P' => 'tongueout', ':$' => 'blush', ':^' => 'wondering', '|-\\' => 'sleepy', '|(' => 'dull', '(inlove)' => 'inlove', '>:)' => 'evilgrin', '(talk)' => 'talking', '(yawn)' => 'yawn', ':&' => 'puke', '(doh)' => 'doh', ':@' => 'angry', '(wasntme)' => 'wasntme', '(party)' => 'party', ':S' => 'worried', '(mmm)' => 'mmm', '8-|' => 'nerd', ':X' => 'lipssealed', '(hi)' => 'hi', '(call)' => 'call', '(devil)' => 'devil', '(angel))' => 'angel', '(envy)' => 'envy', '(wait)' => 'wait', '(bear)' => 'bear', '(makeup)' => 'makeup', '(giggle)' => 'coveredlaugh', '(clap)' => 'clapping', ':?' => 'thinking', '(bow)' => 'bow', '(rofl)' => 'rofl', '(phew)' => 'whew', '(happy)' => 'happy', '(smirk)' => 'smirking', '(nod)' => 'nodding', '(shake)' => 'shaking', '(punch)' => 'punch', '(emo)' => 'emo', '(y)' => 'yes', '(n)' => 'no', '(handshake)' => 'handshake', '(skype)' => 'skype', '(h)' => 'heart', '(u)' => 'brokenheart', '(e)' => 'mail', '(f)' => 'flower', '(rain)' => 'rain', '(sun)' => 'sun', '(clock)' => 'clock', '(8)' => 'music', '(movie)' => 'movie', '(phone)' => 'phone', '(coffee)' => 'coffee', '(pizza)' => 'pizza', '(cash)' => 'cash', '(muscle)' => 'muscle', '(cake)' => 'cake', '(beer)' => 'beer', '(d)' => 'drink', '(dance)' => 'dance', '(ninja)' => 'ninja', '(*)' => 'star', '(mooning)' => 'mooning', '(finger)' => 'finger', '(smoking)' => 'smoking', '(drunk)' => 'drunk', '(bandit)' => 'bandit', '(toivo)' => 'toivo', '(rock)' => 'rock', '(headbang)' => 'headbang', '(bug)' => 'bug', '(fubar)' => 'fubar', '(poolparty)' => 'poolparty', '(swear)' => 'swear', '(tmi)' => 'tmi', '(heidy)' => 'heidy', '(malthe)' => 'malthe', '(tauri)' => 'tauri', '(priidu)' => 'priidu' ); $html = '<a href="#" name="emotes" id="showhide">Toggle Emotes</a><br /><div class="emoticon-list" id="emotes" style="display:none;">'; foreach($emoticons as $short_code => $short_html) $html .= '<img src="images/smilies/skype/' . $short_html . '.gif" data-short-code="' . $short_code . '" />&nbsp;'; $html .= '</div><br /><a href="bbcode.php">Chat Commands</a>'; $js1 = "<script language=\"JavaScript\" type=\"text/javascript\"> <!-- function insertTextAtCursor(el, text) { var val = el.value, endIndex, range, doc = el.ownerDocument; if (typeof el.selectionStart == 'number' && typeof el.selectionEnd == 'number') { endIndex = el.selectionEnd; el.value = val.slice(0, endIndex) + text + val.slice(endIndex); el.selectionStart = el.selectionEnd = endIndex + text.length; } else if (doc.selection != 'undefined' && doc.selection.createRange) { el.focus(); range = doc.selection.createRange(); range.collapse(false); range.text = text; range.select(); } } //--> </script>"; $js2 = "<script type=\"text/javascript\" src=\"http://code.jquery.com/jquery-1.8.3.min.js\"></script>"; $js3 = "<script type=\"text/javascript\"> jQuery(document).ready(function() { jQuery('div.emoticon-list img').click(function() { var jThis = jQuery(this), jMessage = jQuery('input#message'); jMessage.val(jMessage.val() + ' ' + jThis.attr('data-short-code')); }); }); </script>"; $js4 = "<script> var iframeWin = document.getElementById('message').contentWindow; var textObj = iframeWin.document.getElementById('message'); insertTextAtCursor(textObj, jThis.attr('data-short-code')); </script>"; $js5 = "<script> $(document).ready(function(){ $('#showhide').click(function(){ $('#emotes').toggle('slow'); }); }); </script>"; $css = '<style type="text/css"> div.emoticon-list { padding: 5px; border: none; } div.emoticon-list img { cursor: pointer; margin-right: 3px; border: none; width: 20px; height: 20px; } div.emoticon-list img:hover { border: 1px solid #003F87; } </style>'; echo $js5, $html, $css, $js1, $js2, $js3, $js4; } ?> <?php $complete = 1; ?> <?php echo emote(":)");
Output for 4.3.11 - 5.6.28, 7.0.0 - 7.1.0
Warning: preg_replace(): No ending delimiter '/' found in /in/sg2GZ on line 105 Warning: preg_replace(): Unknown modifier '|' in /in/sg2GZ on line 105 Warning: preg_replace(): Compilation failed: missing ) at offset 11 in /in/sg2GZ on line 105 Warning: preg_replace(): Compilation failed: missing ) at offset 8 in /in/sg2GZ on line 105 Warning: preg_replace(): Compilation failed: unmatched parentheses at offset 7 in /in/sg2GZ on line 105
Output for hhvm-3.10.0 - 3.12.0
Warning: No ending delimiter '/' found: [/(8\))|(8\=\))|(8\-\))|(B\))|(B\=\))|(B\-\))|(\(cool\))] in /in/sg2GZ on line 105 Warning: Unknown modifier '|': [(\(blush\))|(\:\$)|(\:\-\$)|(\:\=\$)|(\:\"\>)/i] in /in/sg2GZ on line 105 Warning: Compilation failed: missing ) at offset 11 in /in/sg2GZ on line 105 Warning: Compilation failed: missing ) at offset 8 in /in/sg2GZ on line 105 Warning: Compilation failed: unmatched parentheses at offset 7 in /in/sg2GZ on line 105
Output for 4.3.0 - 4.3.10
Warning: No ending delimiter '/' found in /in/sg2GZ on line 105 Warning: Unknown modifier '|' in /in/sg2GZ on line 105 Warning: Compilation failed: missing ) at offset 11 in /in/sg2GZ on line 105 Warning: Compilation failed: missing ) at offset 8 in /in/sg2GZ on line 105 Warning: Compilation failed: unmatched parentheses at offset 7 in /in/sg2GZ on line 105