access a cookie’s value immediately after calling the setcookie()

If you want to access a cookie’s value immediately after calling the setcookie() you can’t use $_COOKIE. The reason for this is in the nature of the protocol (see https://tools.ietf.org/html/rfc6265). When you use setcookie() it defines a Cookie to be sent along with the rest of the HTTP headers to the client (see http://php.net/manual/en/function.setcookie.php). But […]

mysqladmin to kill the runaway query

Run the following commands: mysqladmin -uusername -ppassword pr Then note down the process id. mysqladmin -uusername -ppassword kill pid

Swap two variables value without using third variable in php

Bit in Expression1 Bit in Expression2 Result 0 0 0 0 1 1 1 0 1 1 1 0 Example with two variable by XOR: $a = 5;               // 5 => 00000101 $b = 6;              // 6 => 00000110 $a = $a ^ $b; // 3 => 00000011   Now XOR of […]

Use of Referencing in php

There are advantages of using references, for example you don’t have to return anything from the function, nor do you have to look to define them as globally accessible. EXAMPLE: function lowercase(&$string){ $string = strtolower($string); } $name = ‘SAJU’; lowercase($name); echo $name; // returns saju

regular expression syntax in php

Example Description ‘/hello/’ It will match the word hello ‘/^hello/’ It will match hello at the start of a string. Possible matches are hello or helloworld, but not worldhello ‘/hello$/’ It will match hello at the end of a string. ‘/he.o/’ It will match any character between he and o. Possible matches are helo or […]