PHP Basics Tutorial: Accessing PHP, Variables, Data Types

PHP Programming for Beginners – Variables, Data Types & PHP Access

PHP anedi web development lo widely used server-side scripting language. PHP ane name originally “Personal Home Page” ane meaning tho start ayindi. Later PHP language develop avvadam tho PHP: Hypertext Preprocessor ane recursive acronym ga use chestunnaru.

PHP mainly dynamic and server-side web applications create cheyadaniki use chestam. HTML webpage structure ni create cheyadaniki useful, while PHP server side lo logic execute chesi dynamic content generate cheyadaniki help chestundi.

For example, user login details process cheyadam, form data receive cheyadam, database nunchi information retrieve cheyadam, user-specific content display cheyadam lanti operations lo PHP use cheyochu.

Ee article lo PHP basic introduction, simple PHP program, PHP files ni ela access cheyali, variables ante enti, variables ni ela create cheyali, PHP data types enti and different data types ni examples tho ela use cheyalo beginners ki easy ga artham ayye vidhamga telusukundam.

PHP full is hypertext preprocessor.olden days php full form is personal home page but now more developments are arrived.thats why it changes to hypertext preprocessor.

Php is used to design server based web pages.it makes connection to the home page to server by using html and PHP.html is used for only web page creation and PHP is used for server connecting web page.

Example Program 1: Using Different Variables

<?php

$name = “Ravi”;

$age = 25;

$city = “Guntur”;

echo “Name: ” . $name . “<br>”;

echo “Age: ” . $age . “<br>”;

echo “City: ” . $city;

?>

Output:

Name: Ravi

Age: 25

City: Guntur

Explanation:

Ikkada three variables create chesam. $name lo name, $age lo age, $city lo city store chesam. echo use chesi values ni webpage lo display chesam.

Example Program 2: Integer and Float Variables

<?php

$quantity = 5;

$price = 120.50;

$total = $quantity * $price;

echo “Quantity: ” . $quantity . “<br>”;

echo “Price: ” . $price . “<br>”;

echo “Total: ” . $total;

?>

Output:

Quantity: 5

Price: 120.5

Total: 602.5

Explanation:

Ee program lo $quantity integer value ni, $price decimal value ni store chestunnayi. Tarvata multiplication chesi total price ni $total variable lo store chesam.

Example Program 3: Boolean Variable

<?php

$isAvailable = true;

if ($isAvailable)
{
echo “Product is available”;
}
else
{
echo “Product is not available”;
}

?>

Output:

Product is available

Explanation:

Ikkada $isAvailable ane variable lo Boolean value true store chesam. Condition true kabatti if block execute ayi product available ani display chestundi.

Example Program 4: Array Variable

<?php

$fruits = [“Apple”, “Banana”, “Mango”];

echo $fruits[0] . “<br>”;

echo $fruits[1] . “<br>”;

echo $fruits[2];

?>

Output:

Apple

Banana

Mango

Explanation:

Ikkada multiple fruit values ni $fruits ane single array variable lo store chesam. Array lo first value index 0, second value index 1, third value index 2 lo untayi. Index use chesi individual values ni access chesam.

Sample application on php:

<?php

echo “welcome to the world…!”

?>

Output:-

welcome to the world…!

Explanation:

echo anedi manaki printf Ela use avuthundo php lo echo alane print cheyadaniki use chestam.

Importance of php:

1.easy to learn:-manam easy ga nerchukoni web page ni create cheyochu

2.platform independent:-E browser lo naina manam install chesukovochu

3.open source:-andaru free ga use chesukovochu.

4.fast execution:-execution anedhi fast ga jarigi output display chestundi

Accessing php files:

After completion of writing php code we should the file as filename.php.here is .php is the extension for php code.

filename.php

How to open the saved file in php:

In any browser search it as

http://localhost/filename.php

Creating sample application of php using variables:

Variable is used to store the values.

Syntax for variable is:

$variablename=value;

Program:

<?php

$name=”sunflower”;

$number=143;

echo $name.”<br>”;

echo $number;

?>

Output:

sunflower

143

Explanation:-

$name ane variable lo sunflower ane value ni store chesukundi.

$number ane variable lo 143ane value ni store chesukundi.

<br>anedi use cheyatam avana a statement break ayyi next line lo print avuthundi.

echo anedi output screen lo print avvataniki use chestam.

identifier in php:

identifier are used for variable names.

$print=”easy subject”;

Here is

$print is variable

print is a identifier

easy subject is a value of the variable.

Data types of php:

There are many data types in php

Integer

Float

Array

String

Boolean

Null

Data types declaration:

For integer:

$num=123;

For float:

$num=12.5;

For string:

$name=”apple”;

For Boolean:

$value=true;

For Null:

$var=Null;

Example program:

<html>

<head>

<title>my program</title>

<body>

<?php

$name=”prabhas”;

$age=21;

$marks=45;

$course=”degree”;

echo $name.”<br>”;

echo $age.”<br>”;

echo $marks.”<br>”;

echo $course.”<br>”;

?>

</body>

</head>

</html>

Output:

prabhas

21

45

degree.

Conclusion

PHP anedi server-side web development kosam useful programming language. PHP code server lo execute ayi, generated result browser ki send avutundi. Dynamic websites and web applications lo forms, user data, database operations and server-side logic kosam PHP ni use cheyochu.

PHP files ni .php extension tho save chestam and local development lo PHP-enabled server environment dwara localhost nunchi access cheyochu.

PHP lo variables data values ni store cheyadaniki use chestam. Variables $ symbol tho start avutayi and variable names case-sensitive. PHP lo Integer, Float, String, Boolean, Array and Null lanti commonly used data types unnayi.

Variables and data types meeda basic understanding PHP programming ki foundation laga work chestundi. Ee concepts clear ga practice chesina tarvata conditions, loops, functions, arrays and database connectivity lanti advanced PHP topics ni understand cheyadam beginners ki easier avutundi.

3 thoughts on “PHP Basics Tutorial: Accessing PHP, Variables, Data Types”

Leave a Comment