Send $http post/get request using ajax or angularjs

If you are using ajax to send form data (especially if you have enctype=”multipart/form-data” for file upload) then use following script to send your request.

For angular js (with in the controller)

            In server side, to accept post request (for both ajax/angularjs)

Continue reading

Convert feeds to json

 

Continue reading

scraper using simple_html_dom.php

Let start with simple_html_dom.php, it an HTML DOM parser, which enables us to find tags on an HTML page and extract content from it. You can download the files from the officail link: link Example 1: To find all images on the website.

Example 2: To find the content of td with class name […]

Continue reading

Change detect in web page

Some time we want requires to detect change in website. It can done easily using few lines of php codes. Just generate md5, of complete website.

  By comparing old and new md5 values, we can detect change.  

Continue reading

Remove .php extension with .htaccess

You may have noticed that in certain websites don’t have any extension in its Url. Example: www.example.com/page.php www.example.com/page It can easily done using  .htaccess files. An .htaccess file is an ASCII file. It is a configuration file for use on web servers running the Apache Web Server software. When a .htaccess file is placed in […]

Continue reading

Date Time in PHP

Date/time is required in almost all the projects. This article is all about how to use date/time efficiently. First thing people often faces is setting timezone. To check default timezone:-

or

Output:-

To set timezone After finding timezone, sometime we want to change it.

Example: date_default_timezone_set(‘Asia/Kolkata’);// this will set timezone to’Asia/Kolkata […]

Continue reading

Difference Between Include And Require in PHP

The include or require statement copies all text/code from a specified file into a file that uses require/include statement. Where to use These statements are useful when you want to include same PHP/HTML etc. pages on multiple pages. Example: Header and footer are written in a sperate file, and are included in various pages. Why […]

Continue reading

PHP code Snippets

Send Mail using mail function in PHP

Short verison for mail function in PHP

Get Remote IP Address in PHP

The above code will not work in case your client is behind proxy server. In that case use below function to get real IP address of client.

Email validation snippet in […]

Continue reading