Started reading PHP


Yesterday Mr. Thyagarajan sir asked us to read PHP .

Today I started reading PHP . I covered basics in PHP . Tomorrow

I will start to read core PHP . It was very interesting 🙂

Today I done very basics task in PHP like

  1. Data types
  2. array
  3. for loop

1 .  First task is about data types .

gettypes is used to find type of datatypes


<html>
<head>
<?php
echo "Data type is PHP !!"."</br>";
$string1 = "php_manual";
$integer = 44;
echo $string1."</br>";
echo gettype($string1)."</br>";
echo $integer."</br>";
echo gettype($integer)."</br>";
?>
</head>
</html>

2.  Float to integer

converting from float to integer


<html>
<head>
<?php
$float_no = 10.234;
echo "this is float number :".$float_no."</br>";
echo "this is converted integer :".(int) ($float_no)."</br>";
echo "<p>This is inline HTML line in PHP</p>";
?>
</head>
<body>
</body>
</html>

 

3.  Array sample program

We can print array in two method .

  1. print_r
  2. var_dump

Unset is used to delete element by key


<html>
<head>
<?php

$arr = array("sathia"=>44 , "thasu" => 10 , "moorthi" => 39 );
echo "ExAMPLE OF PRINTING ARRAY WITH VAR_DUMP"."</br>";
var_dump($arr);
echo "</br><br>ExAMPLE OF PRINTING ARRAY WITH PRINT_R"."</br>";
print_r($arr);
unset($arr["moorthi"]);
echo "</br></br>"."Example of UNSET"."</br>";
print_r($arr);
echo "</br></br>"."UNSET is used to remove element by key"."</br>";
foreach ($arr as $key => $arr1) {
 echo $key." ".$arr1."</br>";
}
?>
</head>
<body>

</body>
</html>

Advertisements

About sathia

Web developer at cloudmint
This entry was posted in Web. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s