Since PHP runs on the server, there is no way to do this using PHP. The text size depends on the operating system, browser (and browser settings, such as scaling) of the client. However, you can use javascript to get the size of the element after rendering it.
height = document.getElementById("elementId").style.height; // Will return 176px for example
width = document.getElementById("elementId").style.width; // Will return 176px for example
Hope this helps
source
share