Sometimes the information you wish to share requires the display of a math equation within the text. One can always create a png, gif or similar image of any math equation, but having an actual math equation-font (which can therefore be sized and colored as you wish using CSS) is in my opinion an improvement.
A company called MathJax makes a math text editor called LaTex that allows you to write out any equation; one of the properties of a LaTex equation is that it can be renderd in HTML on a web page. In the following examples spaces appear in parts of the PHP code--these spaces are in place so that the examples will not actually run.
In order to use MathJax you must enter a script located in the head section of the (in this case PHP) code:
Once you have added the script tag into the head section of the code, you can place the equation-code inside a division. It is simply required that the interior of the division be HTML, not PHP. An example follows. Directly after this line is PHP code; a division is being created...
The division (colored grey to identify it--there are 2 parts) is begun, then PHP ends. That is the meaning of '?>'; PHP has ended. It is with the section directly after '?>' where your LaTex is written; i.e., the HTML-section (example shown in blue).
After the HTML (with LaTex in it) is finished PHP resumes, by writing the code '< ?PHP'. Observe that the first thing done is to end the division. Also note that the equation (written within HTML) is within a PHP div tag! HTML & PHP -- they are combined. The contents of HTML can
be placed anywhere in the web page using either pure HTML, or with CSS, which is a PHP attribute. Example is displayed (from code above):
A company called MathJax makes a math text editor called LaTex that allows you to write out any equation; one of the properties of a LaTex equation is that it can be renderd in HTML on a web page. In the following examples spaces appear in parts of the PHP code--these spaces are in place so that the examples will not actually run.
In order to use MathJax you must enter a script located in the head section of the (in this case PHP) code:
< html>
< head>
< script id='MathJax-script' async src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'>< /script>
< body>
Once you have added the script tag into the head section of the code, you can place the equation-code inside a division. It is simply required that the interior of the division be HTML, not PHP. An example follows. Directly after this line is PHP code; a division is being created...
The division (colored grey to identify it--there are 2 parts) is begun, then PHP ends. That is the meaning of '?>'; PHP has ended. It is with the section directly after '?>' where your LaTex is written; i.e., the HTML-section (example shown in blue).
After the HTML (with LaTex in it) is finished PHP resumes, by writing the code '< ?PHP'. Observe that the first thing done is to end the division. Also note that the equation (written within HTML) is within a PHP div tag! HTML & PHP -- they are combined. The contents of HTML can be placed anywhere in the web page using either pure HTML, or with CSS, which is a PHP attribute.
Example is displayed (from code above):