Category Archives: PhP

Run PHP Compatibility checks for upgrading version

Description: In order to bring the PHP version up to date, we need to run compatibility test on our projects. Solution: The CodeSniffer tool that can be installed on each system gives us the most precise results. Follow the guide … Continue reading

Posted in Best practices, Linux, PhP | Tagged , , , , , | Leave a comment

Requirements for sending e-mails from PHP

Description: We need to send e-mails directly from a PHP script. Solution: First, in php.ini the smtp port should be set to 25, but this is usually by default. To locate your php.ini file in the server configuration you can use … Continue reading

Posted in Linux, PhP, Wordpress | Tagged , , , , , , | Leave a comment

substr() cuts in the middle of & symbol

Description: In “Read more” segments, you often need to cut the text to a length and add ‘…’ at the end. This can be a bit tricky when the limit falls on a special character. Solution: We can use mb_substr() … Continue reading

Posted in Best practices, PhP | Tagged , , , , | Leave a comment

Reversing an Array in PhP

Description: Having an array, how to easily do to reverse the order of the elements. Solution: PhP offers an out-of-the box solution to this issue. It is the function array_reverse() which inverts the order of the array elements. A point to take … Continue reading

Posted in PhP | Tagged , | Leave a comment

Add line break in PDF generated from HTML without fix width

Description: By creating a PDF from HTML if you use tables and you want the table cells to flow easily not depending on the width of a specific cell, a long text is not broken into multiple lines, but the … Continue reading

Posted in Best practices, PhP | Tagged , , , , , | Leave a comment

Format number with decimals without rounding

Description: Trying to get a precise number of decimal in a number results most of the times in a rounding of the number. Both round() and number_format() functions of PhP round the output result. Solution: The solution to this issue is to … Continue reading

Posted in Best practices, PhP | Tagged , , , | 2 Comments

301 and 302 redirect, differences and implementation

Description: Is there any difference between 301 and 301 redirects ? Solution: Practically, there is limited difference between the two. To be precise, 301 redirect signals a permanent move of the page, while 302 reffers to a temporary move. This … Continue reading

Posted in Best practices, PhP, Script, Tools | Tagged , , , | Leave a comment