How to read XML document with xpath using dom4j library

You can create an xml document using SAXReader as given sample below.

We will use the below xml file to read in this example

How to remove query strings from URL using .htaccess

A query string is the stuff after the question mark in URLs.

Remove query string makes you URL more readable and easier to share on social media.

How To Generate tinyURLs in PHP

All you need is allow_url_fopen enabled in your php.ini and PHP version 4.3.0 or higher. If you don't know whether you have allow_url_fopen enabled, just run the function phpinfo(), which displays all of your PHP settings.

This line of code send a request to with necessary parameters and you will get a url of the current page returned.

This line of code send a request to with necessary parameters and you will get a url .

PHP how to set a one-off variable

A one-off variable makes a predicate expression true or false only the first time it's evaluated, the same expression will be opposite false or true ever after. This is useful when there something needs to be done only when the same block of code is executed on the first time. Usually the code block is in a loop, you .

Don't call echo before ob_gzhandler or you get ERR_CONTENT_DECODING_FAILED error

before the invocation for example the below echo "hello"; ob_start('ob_gzhandler ... '); You will get ERR_CONTENT_DECODING_FAILED error, the reason is with the invocation of ob_gzhandler, the HTTP ... The ob_gzhandler will compress(gzip) the output after the its invocation, if you echo anything ... response tells the browser the content is compressed, but the response output before the invocation

Fatal error: Call to undefined function mysqli_connect_error()

The reason is the mysqli.dll is disabled in php.ini file. Open the phpinfo and find ... the configuration file Edit the file and find the following line ;extension=php_mysqli.dll Remove ... the comment. And then restart Apache server. Check the phpinfo again and find mysqli support ... The error will not occur again.

When not to suppress fatal errors with @ in PHP

In PHP the @ is used to suppress warning or error messages, but it has some serious drawbacks ... the @ operator, you can see the error in the response <b>Fatal error</b>: Call to undefined function ... in PHP configuration file. [It breaks AJAX response] If you specified the response format ... of AJAX as JSON, when a fatal error happens, the server will be interrupted and returns ahead of time

How to debug AJAX response in PHP

The simplest way to debug a normal PHP request is using the echo to output messages ... to browser, but in AJAX, it's not working. In an AJAX request, the response usually was not displayed ... the AJAX response is received and check its value in your debugger for example in Chrome Developer Tools. ... . Without other facilities, the only way to debug it is to set the breakpoint at the place where

CURL download speed is very slow on PHP Apache server

I have a service running on Apache server that use curl php to retrieve web pages ... . For unknown reasons, I notice that the download speed gets very slow. But it's not normal, since I issues ... :// ... , not only the download speed is slow, but also the DNS lookup time. DNS lookup took 13.1 seconds

PHP array_multisort two arrays sort by column example

A common problem we run into in day to day PHP programming is to sort two arrays by one ... column. Especially when the data comes from database. We sometimes need to write code to do the things ... from table order by a desc; SQL is a declaration language and good at such tasks, PHP is an imperative ... . There are several ported LINQ for PHP, check them out if you want to save your precious time
1 2 ... 5 Next Page