示例#1
0
<?php

require_once dirname(__FILE__) . '/phplatex.php';
echo texify('$\\(x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}\\)$');
?>
<img src="texImages/A1.png"><img src="texImages/a.svg">
示例#2
0
function bbmath_bbcode($a, &$text)
{
    $text = preg_replace_callback('|\\[tex\\](.*?)\\[/tex\\]|', function ($m) {
        return texify($m[1]);
    }, $text);
}
示例#3
0
         $replace = false;
         $replace = texify('$' . $mathTex . '$');
         if ($replace === false) {
             $replace = '<img src="http://latex.codecogs.com/gif.latex?' . rawurlencode($mathTex) . '">';
         }
         $task = substr($task, 0, $pos) . $replace . substr($task, $pos2 + strlen($second));
     }
     $pos = strpos($task, $first, $pos + strlen($first) + strlen($second));
 }
 $pos = strpos($solution, $first);
 while ($pos !== false) {
     $pos2 = strpos($solution, $second);
     if ($pos2 !== false) {
         $mathTex = substr($solution, $pos + strlen($first), $pos2 - $pos - strlen($first));
         $replace = false;
         $replace = texify('$' . $mathTex . '$');
         if ($replace === false) {
             $replace = '<img src="http://latex.codecogs.com/gif.latex?' . rawurlencode($mathTex) . '">';
         }
         $solution = substr($solution, 0, $pos) . $replace . substr($solution, $pos2 + strlen($second));
     }
     $pos = strpos($solution, $first, $pos + strlen($first) + strlen($second));
 }
 $formId = isset($subexercise['formId']) ? $subexercise['formId'] : null;
 $form = Form::createForm($formId, $exerciseId, $solution, $task, isset($subexercise['type']) ? $subexercise['type'] : null);
 $choiceText = $subexercise['choice'];
 $choices = array();
 foreach ($choiceText as $tempKey => $choiceData) {
     $choice = new Choice();
     $choice->SetText($choiceData);
     $choices[$tempKey] = $choice;