Professional Documents
Culture Documents
Assignment No.1 :
1. Write any 5 advantages of PHP
A. Open Source and Free of Cost :
People can download it for free from any open source
B. Platform Independent :
PHP based application can run on any operating system like Unix,
Window and Linux
C. Easy Loading:
One can load the php based application easily and connect them to
a database
D. Stable :
Unlike other scripting language, it is very stable over the years
E. User Friendly :
It can be learned easily and implemented
C. Float :
a) A float is a number with decimal point
b) Eg :
$x = 3.14;
$y = 5.5;
D. Boolean :
a) A Boolean represents two positive states : TRUE or FALSE
b) Eg :
$x = true;
$y = false;
B. Comparison Operator :
C. Logical Operator :
b) Associative Array:
In an associative array, the indexes are strings that you
define. To create an associative array, you can use the
following syntax:
$array = array(key1=>value1, key2=>value2,
key3=>value3);
Eg:
$ages = array("Peter"=>32, "John"=>28, "Mary"=>21);
c) Multi-dimensional Array:
In a multi-dimensional array, you can have one or more
arrays nested inside another array. To create a multi-
dimensional array, you can use the following syntax:
$array = array(array(value1, value2), array(value3, value4));
Eg :
$students = array(
array("name"=>"John", "age"=>25, "grade"=>85),
array("name"=>"Mary", "age"=>23, "grade"=>90),
array("name"=>"Peter", "age"=>27, "grade"=>75)
);
B. Associative Array:
a) In an associative array, the indexes are strings that you define. To
create an associative array,
b) you can use the following syntax
$array = array(key1=>value1, key2=>value2, key3=>value3);
c) Eg:
$ages = array("Peter"=>32, "John"=>28, "Mary"=>21);
B. strcmp(str1,str2) :
a) This function is case sensitive returns
0 if both str1 and str2 are equal
1 if str1 is greater than str2
-1 I str2 is greater than str1
b) Eg :
$str1 = “Hello”;
$str2 = “hello”;
echo strcmp($str1,$str2);
C. strpos(string,word) :
a) Find position of a given word in a string and it is case sensitive
b) Eg :
$str = “Hello PHP”;
echo strpos($str,”PHP”);
D. str_replace($search, $replace, $subject) :
a) It is used to replace all occurrences of a string with another string
within a given string.
b) Eg :
<?php
$str = "Hello PHP";
echo str_replace("PHP","Uzumaki",$str);
?>
B. ucwords($string) :
a) It converts the first character of each word into upper case letter in
a string
b) Eg:
<?php
echo ucwords(“hello, my name is you”);
?>
C. strlen($string) :
a) Returns the length of a string including all the white spaces and
special characters
b) Eg :
<?php
echo strlen(“Hello World”);
?>
D. strtoupper($string):
a) It is used to convert the string into upper case
b) Eg :
echo strtoupper(“hello world”);
B. Compact() :
a) Used to convert variable to array
b) Syntax :
compact(“variable name”,”variable name”);
c) Eg :
$a = 30 ; $b = 60 ; $c=70;
$d = compact(“a”,”b”,”c”);
print-r($d);