您的位置:首页 > 文旅 > 旅游 > 小微型企业网站建立_排名前十的网页游戏_快速排名程序_百度人工客服电话

小微型企业网站建立_排名前十的网页游戏_快速排名程序_百度人工客服电话

2025/7/19 19:37:51 来源:https://blog.csdn.net/weixin_44936767/article/details/148649845  浏览:    关键词:小微型企业网站建立_排名前十的网页游戏_快速排名程序_百度人工客服电话
小微型企业网站建立_排名前十的网页游戏_快速排名程序_百度人工客服电话
//公式图片转换2.0
function test_latex_to_svg2($latex = '')
{global $WebUrlTi;$filename_url = '';if ($latex) {//对中文括号进行替换,不支持$latex = str_replace(['(', ')'], ['(', ')'], $latex);// 对 LaTeX 公式进行 URL 编码$encodedLatex = rawurlencode($latex);$urldata = 'https://latex.codecogs.com/svg.latex?' . $encodedLatex;// 使用 cURL 获取数据(更稳定)$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $urldata);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 测试时可关闭 SSL 验证$svgContent = curl_exec($ch);curl_close($ch);if ($svgContent === false) {error_log("Failed to fetch SVG: " . $urldata);return '';}// 保存 SVG 文件$filename = build_order_no() . '.svg';$pic_url = $_SERVER['DOCUMENT_ROOT'] . '/image/svg/';if (!file_exists($pic_url)) {mkdir($pic_url, 0777, true);}if (file_put_contents($pic_url . $filename, $svgContent) !== false) {$filename_url = '/image/svg/' . $filename;}}return $filename_url;
}//开始使用
$latex = 'x=\frac {-b\pm \sqrt {{b}^{2}-4ac}} {2a}';
echo test_latex_to_svg2($latex);


找到服务器对应目录的svg文件下载并打开查看


参考网址:https://latex.codecogs.com/

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com