How to show math equation in php / HTML? [closed]

落花浮王杯 提交于 2021-02-05 07:23:07

问题


I have a ckeditor where we can create math equation when I am fetch equation from database it look like a+b2 but I want like (a+b)^2. So, How can I do this? Please help me.

html_entity_decode($post->answer)

I am using html_entity_decode but it not look exactly I want.


回答1:


Browser support for MathML is still rather patchy, but you can get it working in just about any browser by adding the MathJax library to your web document. Just add the following two lines to your HTML:

<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>

It should then render correctly. Try running the following snippet for example:

<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<p>&nbsp;<math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><msup><mfenced><mrow><mi>a</mi><mo>+</mo><mi>b</mi></mrow></mfenced><mn>2</mn></msup><mo>=</mo><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup><mo>+</mo><mn>2</mn><mi>a</mi><mi>b</mi></mrow></math></p>


来源:https://stackoverflow.com/questions/64047281/how-to-show-math-equation-in-php-html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!