Category:PHP

  • Nginx advanced (IV) nginx direct Memcache

    Time:2022-1-19

    Series articles: Nginx advanced part (I) reverse agent to realize dynamic and static separation What is load balancing Nginx advanced part (III) implementation of load balancing Nginx advanced (IV) nginx direct Memcache Nginx can directly connect to Memcache, which is at least 6 times faster than forwarding to PHP through nginx and then accessing the […]

  • be careful! Comparison of strings and numbers in PHP

    Time:2022-1-19

    In the daily development process,Operators are something we come into contact with every day. In fact, there are many pits buried in this operator. Today, let’s look at the use of strings and numbersCompare the problems that need attention. Let’s first look at these codes: echo ‘”1234″ == ” 1234″ is ‘ . (‘1234’ == […]

  • Talk about require in PHP_ Why is the once () function not easy to use

    Time:2022-1-19

    In the previous article “talking about the usage of die () and sleep () functions in PHP”, we briefly introduced the use of die () and sleep () functions. Interested friends can learn about them~ This article will tell you about require in PHP_ Why is once () not easy to use! But before we […]

  • Several ways for ThinkPHP to print SQL statements

    Time:2022-1-18

    Get SQL statement getLastSql $res = Db::table(‘staff’)->field(‘id,salary’)->where(‘id’,’>’,1) ->group(‘salary’)->having(‘salary > 5000’)->select(); $sql = Db::table(‘staff’)->getLastSql(); halt($sql); select(false) $res = Db::table(‘staff’)->field(‘id,salary’)->where(‘id’,’>’,1) ->group(‘salary’)->having(‘salary > 5000’)->select(false); halt($res); fetchSql $res = Db::table(‘staff’)->field(‘id,salary’)->where(‘id’,’>’,1) ->group(‘salary’)->having(‘salary > 5000’)->fetchSql()->select(); halt($res); buildSql $res = Db::table(‘staff’)->field(‘id,salary’)->where(‘id’,’>’,1) ->group(‘salary’)->having(‘salary > 5000’)->buildSql(); halt($res); Listen for SQL Db::listen(function($sql, $time, $explain){ //Record SQL echo $sql. ‘ [‘.$time.’s]’; //View performance analysis results dump($explain); […]

  • Don’t you know PHP has closures? Then you’re really out

    Time:2022-1-18

    After doing web development for some time, we all know or understand that there is a very powerful syntax in JavaScript, that is closure. In fact, the function of closure function has long been available in PHP. As early as version 5.3 of PHP, closure functions have appeared. In 7 and later modern frameworks, the […]

  • Let’s talk about why the = = = operator in PHP is faster than = =

    Time:2022-1-18

    In the previous article “talk about why the require_once() function in PHP is not easy to use”, we introduced the require() function in PHP_ The reason why once () is not easy to use is that interested friends can read it~ So this article will introduce you to PHP===Why do operators compare==Come on? The = […]

  • HTTP get request to body

    Time:2022-1-17

    HTTP get request to body In the past, I saw articles in the community that get requests can be transmitted to the body, but I haven’t encountered them in practice. Now I have gained experience and record it. Implementation, tiktok, huge engine open platform – huge capacity of open access capability – interface document Examples […]

  • Use of goto syntax in PHP

    Time:2022-1-17

    In C + +, Java and many languages, there is a magical syntax, goto. As the name suggests, its use is to go directly to a certain place. From the perspective of code, that is, jump directly to the specified place. We also have this function in PHP. Let’s see how it is used first: […]

  • Sorting and summary of common code segments for PHP operating MySQL

    Time:2022-1-17

    This article introduces the code snippets commonly used in the actual development of practical PHP websites to operate MySQL database. All the codes are reliably executed. This article will be continuously updated!!! 1. Insert data table into database <?php $con = mysql_ Connect (“[database address],” [database user name], “[database password]”)// Create MySQL connection mysql_ select_ […]

  • Why is it recommended to put constants first when using if in PHP?

    Time:2022-1-16

    In the code written by some frameworks or experts, we will find that many people like to write constants in front of conditional judgment, such as: if(1 == $a){ echo 111; } What are the benefits of doing so? Let’s assume that if a careless person writes a = sign less, what will be the […]

  • PHP instance code of renaming after copying the file

    Time:2022-1-16

    1、 с o ру Function to modify the file name after copying the file. This function can copy (copy) a file to the specified directory. 2. Syntax “copy ($file, $newfile)”; Returns true if the execution is successful and false if the execution fails. example <?php header(“Content-type:text/html;charset=utf-8”); $file = ‘test.txt’; $newfile = ‘newtest.txt’; if(copy($file, $newfile)){ Echo […]

  • [yii2] yii2 queue test learning based on redis queue

    Time:2022-1-15

    #Environment versionPhp7.0 under Windows 3 + Yii2. 0.42 basic + redis3 zero point five 1. Download yii2 queue extensioncomposer require –prefer-dist yiisoft/yii2-queue2. Download yii2 rediscomposer require –prefer-dist yiisoft/yii2-redis3. Add the configuration component in the file config \ console php ,config\web. PHP is added ‘redis’ => [ ‘class’ => ‘yii\redis\Connection’, ‘hostname’ => ‘localhost’, ‘port’ => ‘6379’, […]