Friday , January 10 2025

PHP

PHP Tutorial for Beginners – A simple and short PHP tutorial and complete reference manual for all built-in PHP functions. This tutorial is designed for beginners who want to develop a user friendly website.

GET THE SOURCE CODE OF A WEBPAGE

Using the function below you would be able to get the HTML code of any webpage. function display_sourcecode($url) { $lines = file($url); $output = “”; foreach ($lines as $line_num => $line) { // loop thru each line and prepend line numbers $output.= “Line #<b>{$line_num}</b> : ” . htmlspecialchars($line) . “<br>\n”; …

Read More »

DETECT LOCATION OF THE USER

Using the below function you can check the city from which the user is visiting your website. function detect_city($ip) { $default = ‘UNKNOWN’; $curlopt_useragent = ‘Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)’; $url = ‘http://ipinfodb.com/ip_locator.php?ip=’ . urlencode($ip); $ch = curl_init(); $curl_opt = array( CURLOPT_FOLLOWLOCATION …

Read More »

SENDING EMAIL WITH MANDRILL

Mandrill is a powerful SMTP provider. Developers tend to use a third party SMTP provider for better inbox deliveries. For the below function you would have to put a file “Mandrill.php” in the same folder as the PHP file you would be using to send emails. function send_email($to_email,$subject,$message1) { require_once ‘Mandrill.php’; $apikey …

Read More »

How to send sms using php ?

While working on web or mobile applications, you often face a situation where you need to send an SMS to your user either for login purposes or providing them with some information. The below PHP function would help you with it. For sending SMS using any language, you’d need an …

Read More »

How to upload file on server using php ?

We can easily upload a file or image on the server using this php code. Before upload an image or file we should configure php.ini file. In your “php.ini” file, search the file_uploads directive, and change it to On: file_uploads = On

Read More »

How can start session in php ?

A session in php is started using session_start() function. Globle variables (eg. $_SESSION.) are used for session variables. Now we create a page “example_session.php” and start a session with some session variables :

Read More »

You Should Already Know before learn PHP

Before you continue you should have a basic understanding of the following: HTML CSS JavaScript What is PHP? PHP is an acronym for “PHP: Hypertext Preprocessor” PHP scripts are executed on the server PHP is free to download and use PHP is a widely-used, open source scripting language What Can …

Read More »