PHP method to obtain a piece of text to display the width and height of the dot matrix
This article describes how PHP obtains a piece of text to display the width and height of the dot matrix. Share it for your reference. The details are as follows:
define("F_SIZE", 8); define("F_FONT", ""); function get_bbox($text){ return imagettfbbox(F_SIZE, 0, F_FONT, $text); } function text_height ($text) { $box = get_bbox($text); $height = $box[3] - $box[5]; return $height; } function text_width ($text) { $box = get_bbox($text); $width = $box[4] - $box[6]; return $width; }
I hope this article will be helpful to everyone's PHP programming.
Related Articles
How to list 100 100 entries of data into Mysql database (PHP)
This article mainly introduces how to divide 100 million data into Mysql database when the data volume soars. Friends who need it can refer to it2015-07-07php empty, isset, is_null judgment comparison (differences and similarities)
When developing php, I believe that when using the functions: empty, isset, is_null, I encountered some problems. It even brings some security risks to your own programs. Many times, for isset, empty, I think it is almost the same. Therefore, when developing, I didn’t pay attention to it. When a period of process judgment occurs, a bug will occur.2010-10-10Manual configuration and usage instructions for XDebug under Windows
XDebug is a php code debugging tool, which is of great help to programmers to debug programs. Let’s briefly talk about the configuration of XDebug under Windows.2010-07-07PHP method to calculate the number of days difference between two dates
This article mainly introduces the method of php calculating the number of days between two dates. It analyzes the skills of php operating dates in an example. Friends who need it can refer to it.2015-03-03Summary of PHP code optimization skills
When writing programs, we want to minimize the resource usage of our programs, run faster and have less code. PHP's unique syntax mixes C, Java, Perl and PHP's innovative syntax, which can execute dynamic web pages faster than CGI or Perl. PHP embeds programs into HTML documents for execution, and the execution efficiency is much higher than that of CGI that completely generates HTML tags.2015-09-09PHP extends Memcache distributed deployment solution
Although memcached is called a "distributed" cache server, the server side does not have a "distributed" function. The server side only includes memory storage function, and its implementation is very simple. As for the distributed memcached, it is completely implemented by the client library. This distribution is the biggest feature of memcached.2015-12-12Analysis of the method of simply implementing singleton design pattern by php
This article mainly introduces the method of simply implementing single-state design patterns in PHP, and simply analyzes the composition, implementation and usage methods of single-state design patterns. Friends who need it can refer to it2017-07-07PHP realizes the conversion between Gregorian dates and lunar dates
This article mainly introduces the relevant information on PHP to convert Gregorian dates and lunar dates. I hope that you can help you through this article. Friends who need it can refer to it.2017-09-09Verification code applet based on php implementation
This article mainly introduces the specific implementation methods of the verification code applet based on php implementation, and has made detailed annotations, which are conducive to understanding and learning. Friends who need it, let’s take a look.2016-12-12Configure nginx+php environment in Windows platform
Compared with Linux, it is much easier to configure the web environment for Windows, whether it is a one-click installation package or an independent configuration. This time, it is about using NGINX as the local test environment for the web.2015-12-12