12ca printout
12ca printout
Output
4. Output
6.
<html> Output
<body>
Welcome to our school
<?php My car is blue
My dress is
echo "Welcome to our school"."<br>"; My box is
$color="blue";
echo "My car is ".$color ."<br>";
echo "My dress is ".$COLOR ."<br>"; 32:greater than 30
echo "My box is ".$coLOR ."<br>";
21:greater than 20
function trinarytest($n) 12:greater than 10
{ 4:Input a number atleast greater than 10!
$r=$n>30?"greater than 30"
:($n>20?"greater than 20"
:($n>10?"greater than 10"
:"Input a number atleast greater than 10!"));
echo $n.":".$r."\n";
}
trinarytest(32);
echo "<br>";
trinarytest(21);
echo "<br>";
trinarytest(12);
echo "<br>";
trinarytest(4);
?>
</body>
</html>
7.
<html>
<body>
<?php
$a=25;
$b="Hello";
$c=5.7;
echo "Number is : " .$a ."<br>";
echo "String is : " .$b ."<br>"; echo "Float value is : " .$c ."<br>";
$txt="INDIA"; OUTPUT
echo "I love $txt!" ."<br>";
Number is : 25
$x=2; String is : Hello
$y=2; Float value is :
echo $x+$y ."<br>"; 5.7I love
INDIA!
function mytest() 4
{ 0
tatic $a=0;echo $a; 1
$a++; 2
}
Variable x inside function is:
mytest();
echo "<br>"; Variable x outside function
mytest();
echo "<br>"; is: 2
mytest();
function demo()
{
echo "<p> Variable x inside function is: $x </p> ";
}
demo();
echo "<p> Variable x outside function is: $x </p> ";
?>
</body>
</html>
8.
<html>
<body>
<?php
// Use Echo
echo "Welcome to Tamilnadu <br>";
$txt1="Learn PHP";
$txt2="Daily";
$x=5;
$y=4;
echo "<h2>". $txt1. "</h2>";
echo "Study PHP \t" .$txt2. "<br>";
echo $x + $y;
$txt3="Hello";
$txt4="Welcome";
$x=7;
$y=3;
print "<h2>" .$txt3 ."</h2>";
print "Hi \t" .$txt4. "<br>";
print $x + $y;
?>
</body>
</html>
OUTPUT
Welcome to Tamilnadu
Welcome to our school!
******************
Learn PHP
Study PHP Daily
9
Hello
Hi Welcome
10
9.
<html>
<body> Output
<?php
12
echo strlen("Hello world!");
echo "<br>"; 3
echo str_word_count("Good Morning All"); emoclew
echo "<br>"; 6
echo strrev("welcome"); Hello Everyone
echo "<br>"; Good Morning!!!
echo strpos("Hello world!", "world");
PHP Tutorial
echo "<br>";
echo str_replace("Hi","Hello","Hi Everyone");
echo "<br>";
define("GREETING","Good Morning!!!");
echo GREETING;
echo "<br>";
$text='PHP Tutorial';
$text=preg_replace('/(\b[a-z])/i','<span style="color:red;">\1</span>',$text);
echo $text;
?>
</body>
</html>
10.
<html>
<body>
<?php
function word_digit($word)
{
$warr=explode(';',$word);
$result='';
foreach($warr as $value)
{
switch(trim($value))
{
case 'zero':
$result.='0';
break;
case 'one':
$result.='1';
break;
case 'two':
$result.='2';
break;
case 'three':
$result.='3';
break;
case 'four':
$result.='4';
break;
case 'five':
$result.='5';
break;
case 'six':
$result.='6';
break;
case 'seven':
$result.='7';
break;
case 'eight':
$result.='8';
break;
case 'nine':
$result.='9';
break;
}
}
return $result;
}
echo word_digit("zero;three;five;six;eight;one")."<br>";
echo word_digit("seven;zero;one")."<br>";
?>
</body>
</html>
OUTPUT
035681
701
5.
In the Wamp Server Click MySQL - > MySQL Console Window.
Enter password:
2. Database changed
3. Database
emd
emp
empd
employ
information_schema
mysql
schooldb
Tables_in_schooldb
student
8.
9. MySQL [schooldb]> select *from student;
12.
14.
18.
Database
emd
emp
empd
employ
information_schema
mysql
6 rows in set (0.00 sec)