Studied PHP yesterday


Yesterday , Mr.Palaniappan sir asked to read some syntax in php

and asked to practice

These are some Basic concept of array and its syntax that I practiced yesterday :

Arrays :

Printing arrays


<?php
$names[0] = "sathia";
$names[1] = "suresh";
$names[2] = "yogesh";
$names[3] = "venky";
for($i=0;$i<4;$i++) {
 echo $names[$i]."<br />";
}
?>

Seeing array or variable present or not


<?php
$ara = array("hi","hello","how","are","you");
$name = "sathia";
if(isset($ara)){
 echo "present<br />";
 }
else {
 echo "Not Present<br />";
}

if(isset($name)) {
 echo "$name is there";
}

else {
 echo "Not there";
}
?>

Converting Array to Variable

</pre>
<?php
$person = array('name' => 'Fred', 'age' => 35, 'wife' => 'Betty');
extract($person);
echo $name;
?>

Converting variables into array

$color = 'indigo';
$shape = 'curvy';
$floppy = 'none';
$b = compact('color', 'shape', 'floppy');
$names = array('color', 'shape', 'floppy');
$a = compact($names);
echo print_r($a);
?></pre>

Checking Password Field is empty ?

</pre>
<html>
<?php
if(empty($_REQUEST['pass'])) {
echo "enter the password";
}
?>
<body>
<form action = "empty.php" method = "POST">
Name :<input type = "text" name = "uname" />
Password :<input type = "text" name = "pass" />
<input type = "submit" value = "login">
</form>
</body>
</html>

Advertisements

About sathia

Web developer at cloudmint
This entry was posted in Uncategorized. 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