run code in 150+ php & hhvm versions
Bugs & Features
<?php /** * Get real file from code id */ // nl2p // This function will convert newlines to HTML paragraphs // without paying attention to HTML tags. Feed it a raw string and it will // simply return that string sectioned into HTML paragraphs function nl2p($str) { $arr=explode("\n",$str); $out=''; for($i=0;$i<count($arr);$i++) { if(strlen(trim($arr[$i]))>0) $out.='<p>'.trim($arr[$i]).'</p>'; } return $out; } // nl2p_html // This function will add paragraph tags around textual content of an HTML file, leaving // the HTML itself intact // This function assumes that the HTML syntax is correct and that the '<' and '>' characters // are not used in any of the values for any tag attributes. If these assumptions are not met, // mass paragraph chaos may ensue. Be safe. function nl2p_html($str) { // If we find the end of an HTML header, assume that this is part of a standard HTML file. Cut off everything including the // end of the head and save it in our output string, then trim the head off of the input. This is mostly because we don't // want to surrount anything like the HTML title tag or any style or script code in paragraph tags. if(strpos($str,'</head>')!==false) { $out=substr($str,0,strpos($str,'</head>')+7); $str=substr($str,strpos($str,'</head>')+7); } } // test $string = "<p> We want this to be a fun place where we share our love of genre. We just have a few rules. </p> <ol> <li>All fiction submitted to this site is subject to the disclaimers as shown. Specific to fan fiction, all such work is posted with the understanding that all copyrighted materials are the property of their respective creators and/or owners.</li> <li>Stories must be submitted to the proper category. If there is an appropriate sub-category, <strong>DO NOT</strong> add your story to the main category.</li> <li>Titles and summaries must be suitable general audiences (including children). No exceptions. Keep the "mature content" within the actual chapters themselves, thank you.</li> <li>A number of authors have requested that fans refrain from writing fan fiction based on their work. Therefore submissions will not be accepted based on the works of P.N. Elrod, Raymond Feist, Terry Goodkind, Laurell K. Hamilton, Anne McCaffrey, Robin McKinley, Irene Radford, Anne Rice, and Nora Roberts/J.D. Robb. This list will be revised as needed.</li> <li>Correct grammar and spelling are expected of all stories submitted to this site. The site administrators are not grammar Nazis. However, the site administrators reserve the right to request corrections in submissions with a multitude of grammar and/or spelling errors. If such a request is ignored, the story will be deleted.</li> <li>All stories must be rated correctly and have the appropriate warnings. All adult rated stories are expected to have warnings. After all, they wouldn't have that rating if there wasn't something to be warned about! The site administrators recognize that there is an audience for these stories, but please respect those who do not wish to read them by labeling them appropriately.</li> <li><strong>The following stories are NEVER allowed within this archive - so don't even ask:</strong> <ul> <li>Real person (i.e., actor/actress, band, singer, etc.) fiction</li> <li>Sex with minors</li> <li>Beastiality/zoophilia (NOTE: This specifically refers to NON-SENTIENT creatures - we understand that in the realm of science fiction and fantasy there are creatures who may have animalistic appearances who are indeed self-aware, intelligent and conscious)</li> <li>Script Format - Fiction is expected to be in narrative format. Also, there have been many instances of scripts posted on the web that later lead to lawsuits and other such unpleasantness (come on, if you write a script, and then a TV show or movie appears that is very similar, you know you're gonna ask questions). How about we avoid problems all together and just not do it, okay?</li> <li>Slash - The reason slash is specifically disallowed is because, by its definition, slash is the romantic and/or sexual pairing of characters in relationships that go against the established canon of their respective universes. The most (in)famous examples include Kirk/Spock, Han/Luke, Frodo/Sam, Josef/Mick, etc. To be brief, these kinds of pairings are akin to describing Luke Skywalker as a dark-eyed brunette, or claiming that Captain Jack Harkness (Torchwood) is heterosexual. A character's sexual orientation (at least as portrayed in canon material) is as intrinsic as eye color, hair color, height, etc. - in otherwords, an immutable quality that, if changed, has changed the essence of the character himself or herself. We absolutely have no problem with LGBT pairings and relationships - just do it with your own original characters unless otherwise established in the canon material.</li> </ul> </li> <li>Stories with multiple chapters should be archived as such and NEVER as separate stories. Simply create a new story, and add chapters to it. If you have trouble with this, please contact the site administrator or ask a friend to help you.</li> <li>Spoiler warnings are <strong>mandatory</strong> for all stories that pertain to current books, television series or movies (i.e., books that have been out less than six months, television series that are still in production, and films that are still in first release in a movie theater).An appropriate spoiler warning to place in your summary would be: Spoilers for Star Trek II: The Wrath of Khan.<strong>DO NOT</strong> do anything like this: Spoilers for the one where Spock dies.</li> </ol> Submissions found to be in violation of these rules may be removed and the author's account suspended at the discretion of the site administrators and/or moderators. The site administrators reserve the right to modify these rules as needed."; $para = nl2p($string); echo $para; ?>
Output for 5.4.0 - 5.6.21, 7.0.0 - 7.1.0RC4
Parse error: syntax error, unexpected 'mature' (T_STRING) in /in/VLb8v on line 50
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Fatal error: syntax error, unexpected T_STRING in /in/VLb8v on line 50
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/VLb8v on line 50
Process exited with code 255.