3v4l.org

run code in 300+ PHP versions simultaneously
<?php $student_comment_new = 'PDI+PEwuMDIwMzEwNDAwODAtVC01UC01PlJvbiBDb21tZW50IDI8ZS4yPg=='; $fixed = base64_decode($student_comment_new); echo $fixed . "\n\n"; //Decode the entire comment $comment_cltxt = base64_decode($student_comment_new); echo $comment_cltxt . "\n\n"; //get the comment number. $comment_nr = explode('><L.', $comment_cltxt)[0]; $comment_nr = explode('<', $comment_nr)[1]; //get the comment end-text $comment_nr_string = '<' . $comment_nr . '>'; $comment_end_string = '<e.' . $comment_nr . '>'; echo $comment_nr . "\n"; echo $comment_nr_string . "\n"; echo $comment_end_string . "\n"; //get the comment text itself $pos1 = substr($comment_cltxt, 0, strlen(comment_nr_string)); $pos2 = substr($comment_cltxt, strlen($comment_cltxt) - strlen($comment_end_string)); $comment_text = substr($comment_cltxt, $pos1, $pos2); echo $comment_text . "\n";
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
<2><L.02031040080-T-5P-5>Ron Comment 2<e.2> <2><L.02031040080-T-5P-5>Ron Comment 2<e.2> 2 <2> <e.2> Fatal error: Uncaught Error: Undefined constant "comment_nr_string" in /in/RTsIt:26 Stack trace: #0 {main} thrown in /in/RTsIt on line 26
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
<2><L.02031040080-T-5P-5>Ron Comment 2<e.2> <2><L.02031040080-T-5P-5>Ron Comment 2<e.2> 2 <2> <e.2> Warning: Use of undefined constant comment_nr_string - assumed 'comment_nr_string' (this will throw an Error in a future version of PHP) in /in/RTsIt on line 26 Warning: substr() expects parameter 2 to be int, string given in /in/RTsIt on line 28
Output for 7.2.0 - 7.2.33
<2><L.02031040080-T-5P-5>Ron Comment 2<e.2> <2><L.02031040080-T-5P-5>Ron Comment 2<e.2> 2 <2> <e.2> Warning: Use of undefined constant comment_nr_string - assumed 'comment_nr_string' (this will throw an Error in a future version of PHP) in /in/RTsIt on line 26 Warning: substr() expects parameter 2 to be integer, string given in /in/RTsIt on line 28
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
<2><L.02031040080-T-5P-5>Ron Comment 2<e.2> <2><L.02031040080-T-5P-5>Ron Comment 2<e.2> 2 <2> <e.2> Notice: Use of undefined constant comment_nr_string - assumed 'comment_nr_string' in /in/RTsIt on line 26 Warning: substr() expects parameter 2 to be integer, string given in /in/RTsIt on line 28
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
<2><L.02031040080-T-5P-5>Ron Comment 2<e.2> <2><L.02031040080-T-5P-5>Ron Comment 2<e.2> 2 <2> <e.2> Notice: Use of undefined constant comment_nr_string - assumed 'comment_nr_string' in /in/RTsIt on line 26 Warning: substr() expects parameter 2 to be long, string given in /in/RTsIt on line 28

preferences:
261.39 ms | 402 KiB | 330 Q