Codetime
0 FOLLOWERS
Keep up with articles from Codetime.
Codetime
4y ago
How to display output in PHP using echo and print.
PHP Echo and Print
PHP Echo statement
Let’s start with echo statement. The echo statement can display anything in the browser such as strings , numbers , variables e.t.c.
The echo statement can have more than one parameters but when you have more than one parameter, you must not enclose it in paranhesis.
Let’s take a quick example. The code below will print Hello world using the echo statement.
Result
Display HTML using Echo statement
You can also display HTML codes using the echo also.
This is what I mean.
Here is th ..read more
Codetime
4y ago
PHP Syntax
PHP script starts with the <?PHP and ends with the ?> tag.
This tells the computer or the editor that the code that will be within the <?php an ?> are PHP code.
The PHP code ends with a semicolon (;).
The semicolon denotes the end of a statement.
Note: Save your PHP documents as '.php’ extension.
Embedding PHP within HTML file.
PHP file can be embedded within HTML file and the normal syntax will follow and also HTML file can be embedded within PHP file also.
The code below shows how to embed PHP code in HTML. The code when displayed on the browser w ..read more
Codetime
4y ago
Introduction to PHP
PHP stands for Hypertext Preprocessor. It was initially known as Personal Home Page.
PHP is a popular general-purpose scripting language that is especially suited to web development [5] . It was originally created byR Lerdorf in 1994; the PHP reference implementation is now produced by The PHP Groups.
PHP script are executed on the server and the result is sent to the web browser as plain HTML.
The current version of PHP is 7. So all the tutorial on my blog are based on PHP 7.
Why learn PHP
PHP is a very powerful modern programming tool such that websites like Face ..read more
Codetime
4y ago
In this tutorial, we would learn to write a program in C++ to check whether a number is even or odd.
#include <iostream>
using namespace std;
int main()
{
int n;
cout<<"Enter an integer : ";
cin>>n;
if(n % 2 == 0)
{
cout<<n<<" is even.";
}
else
{
cout << n << " is odd.";
}
return 0;
}
Tutorial
HTML tutorial
CSS tutorial
JavaScript Tutorial
Web de ..read more
Codetime
4y ago
In this tutorial, we would learn to write a program in C++ to find the largest or smallest number of 3 different numbers.
#include<iostream>
using namespace std;
int main()
{
//declaration of variables
int num1, num2, num3;
int smallest, largest;
//take input from user
cout << "Please enter 3 numbers : "<<"" ;
cin >> num1 >> num2 >> num3;
//assign initial value for comparison
smallest = num1;
largest = num1;
if ..read more
Codetime
4y ago
In this tutorial, we would learn to add numbers together.
Imagine when you have up to 30 numbers you want to add.
• The first thing you need is speed. How fast can you add 30 numbers
• Second is accuracy. How accurate will your answer be when you add them. How do you avoid mistakes.
That is the major reason why you need to write a program.
Here is the code in C++
#include<iostream>
using namespace std;
int main()
{
int times, num, sum,i;
times=num=sum=i=0;
cout << "Input the number of integers you want to add:";
cin ..read more
Codetime
4y ago
In this tutorial, we would learn to swap two numbers and write a program in C++ .
Swapping two numbers manually is one of the easiest thing to do but imagine you writing a program that will do this very fast.
#include<iostream>
using namespace std;
int main()
{
int num1, num2, swap;
cout<<"Enter first number: ";
cin>>num1;
cout<<"Enter second number: ";
cin>>num2;
cout<<"\nValues Before swapping: \n"<<endl;
cout<<"First Integer ="<<num1<<endl;
cout<<"Seco ..read more
Codetime
4y ago
In this tutorial,we would learn to write a program in C++ to reverse numbers.
#include <iostream>
using namespace std;
int main()
{
int number, reverse = 0;
cout<<"Input a Number to Reverse ";
cin>> number;
while(number!= 0)
{
reverse = reverse * 10;
reverse = reverse + number%10;
number = number/10;
}
cout<<"New Reversed Number is: "<<reverse;
return 0;
}
Tutorial
HTML tutorial
CSS tutorial
JavaScript Tutorial
Web devel ..read more
Codetime
4y ago
In this tutorial, we would learn to write C++ program to find the factorial of any number.
The program will ask user to enter number then the program will find the factorial and then print the factorial of the number.
Here is the code.
#include<iostream>
using namespace std;
int main()
{
int num,factorial=1;
cout<<"Enter number ";
cin>>num;
for(int a=1;a<=num;a++)
{
factorial=factorial*a;
}
cout<<"Facto ..read more
Codetime
4y ago
In this tutorial , we would learn to write a code in C++ to check whether a particular number we enter is a palindrome.
#include<iostream>
using namespace std;
int main()
{
int i,temp,d,revrs=0;
cout<<"Enter the number : ";
cin>>i;
temp=i;
while(temp>0)
{
d=temp%10;
temp/=10;
revrs=revrs*10+d;
}
if(revrs==i)
cout<<i<<" i ..read more