PHP for Loop

In this lesson, you will learn how to use loops in PHP code – especially the “For loop.” In php, loops are used to execute the same code for a specified number of times or until an expression is met. This would help developers to write a minimal code while avoiding repetition. Overview of for... » read more

PHP Switch statement

In this lesson, you will learn how to use the PHP switch statement which lets you an easy alternative of writing multiple if-else statements. PHP switch Statement PHP switch statement compares a variable or an expression against many different values and executes an associated code block if the comparison results as Boolean value true. Example... » read more

PHP if-else

In this lesson, you will learn how to use conditional statements in PHP. Conditional statements can change the flow of the program depending on the conditions being met. PHP if statement The ‘if statement’ is a conditional statement in PHP which evaluates an expression between parenthesis. If this expression is evaluated as true, the block... » read more

PHP Operators

In this lesson, you will learn how to use PHP operators to perform arithmetic and logic operations on the data. An operator takes one or more variable known as operands, to manipulate data items. PHP has followed the syntax of C and Perl for its operators. PHP Operators Below are the most utilized operators in... » read more

PHP Strings

In this lesson, you will learn how to create, store or manipulate strings in PHP. A string is a type that contains letters, numbers, and symbols or a combination of these. How to create a string in PHP The simplest way to create a string in PHP is to enclose the string literal in single... » read more

PHP Echo and Print

In this lesson, you will learn about echo and print statements. We have already seen hello.php example in Lesson 1 when the echo statement is used to display a text string. PHP’s primary function is to output HTML. Almost every action PHP performs ends up with outputting HTML onto a webpage. PHP Echo Statement In... » read more

PHP Variables

In this lesson, you will learn about variables in PHP. A variable is a special container that you can define to hold data or value. PHP is a loosely typed programming language, but there are a few rules about declaring and storing variables. Introduction to PHP Variables Below are the rules when it comes to... » read more

PHP Syntax

In this lesson, we will teach you the basic syntax of PHP language. PHP files are saved with .php extension. Inside a PHP file, you can write HTML code just like you do in regular HTML pages as well as embedded PHP code blocks to execute on the server-side. PHP is a quite simple language... » read more

Introduction to PHP

What is PHP? PHP code can be embedded into the HTML page, and after the execution, it will generate HTML which is sent to the client. The client will only be able to see the HTML and would not know the PHP code behind the HTML. The best thing about PHP is it is not... » read more

Convert a Binary Number into Decimal in C

Binary numbers are represented in the base of 2. For example 110112, 1002, etc. In this article, we will be converting a binary number into a decimal number which is represented in base 10 using C language. In the conversion, there are mainly three steps to be followed. The first thing is to get the remainder... » read more

Get the phone’s last known location using Android

the code below will return the lasted known location of the phone using the Android platform. Get Phone location in Android import android.location.LocationManager; public double[] getGPSLocation() { double[] LatLong = new double[2]; LocationManager _locationmanager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); List<String> _providers = _locationmanager .getProviders(true); Location _location = null; for (int i = _providers.size()-1; i>=0; i--) { _location... » read more

Convert a Stream to Array using Java 8

In the code below converts a Stream to an Array with Java 8. The Java 8 Library contains the .toArray() function that makes it easier to convert Datatypes to an array type. Convert a stream to an Array in Java import java.util.Arrays; public class Main { public static void main(String[] args) { String str =... » read more