Подсветка php кода - Visavi.net https://visavi.net/ RSS - Visavi.net https://visavi.net/assets/img/images/logo_small.png RSS - Visavi.net https://visavi.net/ [email protected] (admin) [email protected] (admin) Fri, 10 Jan 2025 15:26:14 +0300 не тот кусок выложил<br> косяк в регулярке https://visavi.net/topics/31025/541377 Подсветка php кода ramzes Mon, 16 Apr 2012 21:23:13 +0400 Сообщения https://visavi.net/topics/31025/541377 Что-то я не понял, где тут бб код, по-моему, ты 2 раза скопировал одно и то же. 2 - автор как раз использует эту функцию, highlight_string, смотри внимательней. https://visavi.net/topics/31025/541333 Подсветка php кода Петр Mon, 16 Apr 2012 20:29:55 +0400 Сообщения https://visavi.net/topics/31025/541333 Zachem ti velosiped opjat delaesh? V php uzhe est takaja funkcija syntax_highlight() ili kak tam ona, pasmotri v google <img src="https://visavi.net/uploads/stickers/smile.gif" alt="smile"> https://visavi.net/topics/31025/541303 Подсветка php кода screamlt Mon, 16 Apr 2012 18:51:06 +0400 Сообщения https://visavi.net/topics/31025/541303 Хочу сделать подсветку php кода, использую функцию:<br> <pre class="prettyprint"> function highlight_code($code) { $code = strtr($code,array(&#039;|&#039;=&gt;&#039;|&#039;,&#039;&lt;&#039;=&gt;&#039;&lt;&#039;,&#039;&gt;&#039;=&gt;&#039;&gt;&#039;,&#039;&amp;amp;&#039;=&gt;&#039;&amp;&#039;,&#039;$&#039;=&gt;&#039;$&#039;,&#039;&quot;&#039;=&gt;&#039;&quot;&#039;,&#039;&#039;&#039;=&gt;&quot;&#039;&quot;,&#039;\&#039;=&gt;&#039;`&#039;,&#039;%&#039;=&gt;&#039;%&#039;,&#039;^&#039;=&gt;&#039;^&#039;,&#039;&#58;&#039;=&gt;&#039;&#58;&#039;,&#039;&lt;br /&gt;&#039;=&gt;&quot;\r\n&quot;)); if(!strpos($code,&#039;&lt;?&#039;) &amp;&amp; substr($code,0,2)!=&#039;&lt;?&#039;) {$code=&quot;&lt;?php\r\n&quot;.trim($code);} $code = highlight_string($code,true); $code = strtr($code,array(&quot;\r\n&quot;=&gt;&#039;&lt;br /&gt;&#039;,&#039;|&#039;=&gt;&#039;|&#039;,&#039;$&#039;=&gt;&#039;$&#039;,&quot;&#039;&quot;=&gt;&#039;&#039;&#039;,&#039;`&#039;=&gt;&#039;\&#039;,&#039;%&#039;=&gt;&#039;%&#039;,&#039;^&#039;=&gt;&#039;^&#039;,&#039;&#58;&#039;=&gt;&#039;&#58;&#039;)); $code = &#039;&lt;div class=&quot;d&quot;&gt;&#039;.$code.&#039;&lt;/div&gt;&#039;; return $code; } </pre> -----<br> бб код:<br> <pre class="prettyprint"> function highlight_code($code) { $code = strtr($code,array(&#039;|&#039;=&gt;&#039;|&#039;,&#039;&lt;&#039;=&gt;&#039;&lt;&#039;,&#039;&gt;&#039;=&gt;&#039;&gt;&#039;,&#039;&amp;amp;&#039;=&gt;&#039;&amp;&#039;,&#039;$&#039;=&gt;&#039;$&#039;,&#039;&quot;&#039;=&gt;&#039;&quot;&#039;,&#039;&#039;&#039;=&gt;&quot;&#039;&quot;,&#039;\&#039;=&gt;&#039;`&#039;,&#039;%&#039;=&gt;&#039;%&#039;,&#039;^&#039;=&gt;&#039;^&#039;,&#039;&#58;&#039;=&gt;&#039;&#58;&#039;,&#039;&lt;br /&gt;&#039;=&gt;&quot;\r\n&quot;)); if(!strpos($code,&#039;&lt;?&#039;) &amp;&amp; substr($code,0,2)!=&#039;&lt;?&#039;) {$code=&quot;&lt;?php\r\n&quot;.trim($code);} $code = highlight_string($code,true); $code = strtr($code,array(&quot;\r\n&quot;=&gt;&#039;&lt;br /&gt;&#039;,&#039;|&#039;=&gt;&#039;|&#039;,&#039;$&#039;=&gt;&#039;$&#039;,&quot;&#039;&quot;=&gt;&#039;&#039;&#039;,&#039;`&#039;=&gt;&#039;\&#039;,&#039;%&#039;=&gt;&#039;%&#039;,&#039;^&#039;=&gt;&#039;^&#039;,&#039;&#58;&#039;=&gt;&#039;&#58;&#039;)); $code = &#039;&lt;div class=&quot;d&quot;&gt;&#039;.$code.&#039;&lt;/div&gt;&#039;; return $code; } </pre> -----<br> Но проблема в том, что если я пишу код в одну строчку, бб код срабатывает, а если делаю переносы, бб код не работает.<br> Тоесть если [коде] echo &#039;test&#039;; [коде] - работает<br> А если<br> [коде]<br> echo &#039;test&#039;;<br> echo &#039;test&#039;;<br> [/коде] - Не работает<br> <br> В чём может быть проблема ? https://visavi.net/topics/31025/533609 Подсветка php кода Евгений Tue, 03 Apr 2012 22:16:02 +0400 Сообщения https://visavi.net/topics/31025/533609