Category Archives: PHP

Format number with leading zero

Format number with leading zero You are having some number which should contain eight digits in it as the registration number. So for the first registration, the number should be 00000001 and for the next 00000002, similarly 00012456, 00002158, 01234568, 25634897 and so on till 99999999. To achieve this we need to format a number… Read More »

How to convert date MM/DD/YYYY to YYYY-MM-DD

How to convert date MM/DD/YYYY to YYYY-MM-DD In real time development we usually come across this issue. But converting the date MM/DD/YYYY to YYYY-MM-DD is really simple using the PHP date function and strtotime() function. In many cases we show different date format like MM/DD/YYYY to users in the application but we need to convert… Read More »

Get client real ip address in PHP

Get client real ip address in PHP [dropcap]In[/dropcap] php we can use superglobal variable $_SERVER to get client informations. $_SERVER is an array containing client informations such as ip address, headers, paths. We can not say all the details will be available in the variable. It depends on the server configurations. Many servers gives $_SERVER[‘REMOTE_ADDR’]… Read More »

How to check if the request is made via ajax in PHP

How to check if the request is made via ajax in PHP [dropcap]N[/dropcap]owadays most of the website uses ajax requests for different purposes. To load a page, to load extra contents, to load images, and many others. And many of the sites are using the ajax request in the login and registration forms. So how… Read More »