- Addition (+)
Addition is performed with the "+" symbol.
Ex:
$total = 5 + 6;
Here 5 add to 6 and assign to the total variable
- Subtract (-)
Subtract is performed with the "-" symbol.
Ex:
$answer = 8 - 6;
- Multiplication (*)
Multiplication is performed with the "*" symbol.
Ex:
$answer = 5 * 6;
This blog supports beginners to get deep knowledge about programming in HTML, CSS, JavaScript, php, asp and other Web technologies and VB, VB.net, Java,step by step from the beginning. All the programming Concepts discuss with simple examples for the readability. Try out daily uploaded lessons to be a Programmer.
PHP - Arithmetic Operations
PHP - Variables and Data types
What is a Variable?
Variables are used to store values into the system's memory. Variables allows to perform set of actions and can be re-use within the code. You can change the out put of the program by changing the variable values rather changing the script.
Data Types
String : used for character values such as sentences, names stc
Integer : used to store numeric values of whole numbers
Float : used to store numeric values of real numbers
Boolean: used to store either true or false or 1 or 0
Object : used to store collection of values (data) or methods
Important: PHP is loosely typed language, that means your script determines the data type of the variable.
Ex:
$val = "PHP Programming" // This is considering as String Value
$val = 50 // This is considering as Integer Value
$val = "100" //This is considering as String value
$val = $val * 5 // This is considering as Integer value
$val = $val * 1.25 //This is considering as float value
PHP - Embeded HTML
This post desribe about the PHP scripting, html coding and embedded php scripts.
I'll explain those with an example.
<html>
<head>
<title>Embedded php</title>
</head>
<body>
<hr />
<h3>Embedded php</h3>
<p>This is a regular HTML paragraph</p>
<?php
echo "<p>This is a php paragraph</p>";
?>
<hr />
</body>
</html>
Above code displays following output.
This is a php paragraph.
I'll explain those with an example.
<html>
<head>
<title>Embedded php</title>
</head>
<body>
<hr />
<h3>Embedded php</h3>
<p>This is a regular HTML paragraph</p>
<?php
echo "<p>This is a php paragraph</p>";
?>
<hr />
</body>
</html>
You can see the text inside the php script and out side it. Text inside the php script (comes with echo statement) handled as a script and rest of the text rendered as regular HTML. We can include any no of php blocks inside the html document like java script and any html tag to embedded the code.
Embedded php
This is a regular HTML paragraphThis is a php paragraph.
PHP - Install a Web Server
- Wamp Server
This video instruct you how to install wamp server - Xampp server
This video instruct you how to setup xampp server on linux (Fedora)
PHP - My First PHP Program
This is a basic php embeded HTML program.
<?php
echo "<h3>Hello This is my First PHP Program </h3>";
?>
<?php
print ("<h3>Hello This is my First PHP Program </h3>");
?>
According to the above program you can appear Following out put
<?php
echo "<h3>Hello This is my First PHP Program </h3>";
?>
<?php
print ("<h3>Hello This is my First PHP Program </h3>");
?>
According to the above program you can appear Following out put
Hello This is my First PHP Program
- echo and print statements are use to write something in the browser. Within the echo statement we can use html tags to format the text.
PHP - Comments
There are 02 comments used with PHP scripts.
- Single line Comment
Single line comments can be specified by //
Ex:
<?php
// This script print Hello World in the browser
echo "Hello World"
?> - Multiple line Comment
Multiple Line Comment begins with "/*" and ends with */.
Ex:
<?php
/* This is a multiple line comment You can comment
any no of lines within this block
*/
echo "Hello World"
?>
PHP - How to create php files
Normally PHP script block starts with <?php and ends ?> and it can be embedded with HTML. PHP block can be placed anywhere in the document either with html tags or not.
HTML Embeded php code
<html>
<head>
<title>This is my First PHP Program</title>
</head>
<body>
<?php
echo "This is my First PHP Program";
?>
</body>
</html>
Pure PHP Code
<?php
echo "This is my First PHP Program";
?>
Shorthand PHP Code
Following code executed when the shorthand mood enabled in the server.
<? echo "This is my First PHP Program"; ?>
It is necessary to specify extention of the php file name as ".php" other wise php scrip does not execute.
Ex: Hello.php
PHP
Today onward I'm starting to teach all of you about the server side
programming with php. I think these posts are much more interesting for
you and hope you enjoy programming with php. Your comments highly
appreciate.
Best Wishes,
Priyal
PHP - How to Execute Script
PHP scripts are unable to execute as normal html web pages thus php scripts are run only on the web servers. Therefore before executing the scripts, you should run your web server. All the php pages should be located inside the web server folder.
- Through Wamp Server
Running wamp server and put it online before doing the execution. You can see a folder named "www" inside the wamp folder located in your C drive. PHP script pages should be located within that folder. It is better to create a folder and save all the documents there.
PHP files cannot access with its full path like html (Ex: C:/wamp/www/php/hello.php). That www folder act as your local web server stored location and therefore you can call the above path "http://localhost/php/hello.php".
localhost or 127.0.0.1 : this is the dns address of your web server located in your machine.
php : php folder created in www folder.
I think now you are familiar with storing php script pages.
See how to run php files with wamp server
PHP - Introduction
- What is PHP?
PHP is stand for PHP Hypertext Preprocessor. PHP is a widely used open source general purpose serverside scripting language for web developing and can be embeded into HTML. PHP originally created by Rasmus Lerdorf and now it is produced by PHP group. Initially it stood as Personal Home Page but now stand for this way. This is an successful free alternative to other web competitors such as Microsoft Asp. Currently php 5.5.0 version released and available from 21st March 2013.
In this note set I'm going to discuss about php and how to execute scripts on your server. - PHP supports many Databases
- PHP is an open source Software
- PHP is a free Software
- PHP is a server side scripting language and executed on the server
- Why PHP
PHP is open source solution and runs on every platform such as Windows, Linux, Unix and etc. and compatible with all web servers such as Apache, IIS & Etc - Before you start PHP programming needed to install php in your machine. It is better to download wampserver for windows and xamp server for linux. This includes Apache, php, Mysql and other technologies required for web programming.
- Links for Downloads
HTML Drop Down List
- Select tag
This tag defines a drop down list to select chices
Syntax:
<select>
<option>Choice 1</option>
<option>Choice 2 </option>
</select> - Option tag uses to define the choices of the list. This should be within the select tag.
Ex:
Code:
<form>
Designation:
<select>
<option>Mr. </option>
<option>Mrs. </option>
<option>Ms. </option>
<option>Dr. </option>
<option>Rev. </option>
<option>Prof. </option> <option>Other. </option></select>
Output :
Designation:
Subscribe to:
Posts (Atom)