Output HTML From Your PHP Script

In this tutorial, I’ll show you how to output HTML from a PHP script. This is very similar to our tutorial on outputting text using PHP (for example, creating your first script to output the text “hello world”), but we’ll be looking at HTML. HTML is the language of the web, so you’ll encounter it … Read more

Categories PHP

Dynamically Add Text to Image in PHP

This tutorial will tell you how to dynamically write text to an image in PHP. This is fairly simple, so it will just be the first step in a series of tutorials dealing with images in PHP. The image functions require the GD library to be installed. Adding text to a blank dynamically generated image … Read more

Categories PHP

Generate a Month Calendar in PHP

This article shows you how to display a calendar for a given month, mainly using PHP’s date() function. The date() function The date() function displays the date in your desired format, at a given time. It works by accepting one or two parameters, the first is a string with the format, the letters in the … Read more

Categories PHP

Raise a Number to a Power in PHP

You might need to raise a number to the power of another (the exponent) in a PHP script, for example \(2^3=2×2×2\) (sometimes written \(2^3\)), or in general \(x^n\). This may also be used with negative powers where \(x^{−n}=\frac{1}{x^n}\). Of course, you’d probably want to do this for more complicated examples! There are two ways to … Read more

Categories PHP

Calculate Square Roots in PHP

To find the nth root of a number in PHP, we can use the pow(base, power) function, for example the cube root of 27 is equal to 27 raised to the power of 1/3, \(\sqrt[3]{27} = 27^{1/3}\), since \(3^3=27\). In general the nth root of x, \(\sqrt[n]{x}=x^{1/n}\). To calculate the square root of a number, … Read more

Categories PHP