The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications.
Monday, February 9, 2009
Saturday, August 16, 2008
Explain when to use GET or POST. Provide example for both the ways.
11:10 PM
No comments
Both GET and POST are used to collect data from a form. However, when security is desired $_POST should be used. When the $_ POST variable is used, all variables used are NOT displayed in the URL. Also, they have no restrictions to the length of the variables. GET should be used when the interaction with the form is more like a question. For e.g. firing a query etc. POST should be used more often when the interaction is more like an order or the interaction changes the state of the resource.
POST example:
Name:
Age:
On clicking submit the URL resembles to: http://www.mysamplesite.com/sample.php
The sample.php file can be used for catching the form data using $_POST
Hello <?php echo $_POST["name"]; ?>.
You are <?php echo $_POST["age"]; ?> years old!
GET EXAMPLE
Name:
Age:
On clicking submit the URL resembles to : http://www.mysamplesite.com/sample.php?name=jim&age=37
The sample.php file can be used for catching the form data using $_GET
Hello <?php echo $_GET["name"]; ?>.
You are <?php echo $_GET["age"]; ?> years old!
POST example:
Name:
Age:
On clicking submit the URL resembles to: http://www.mysamplesite.com/sample.php
The sample.php file can be used for catching the form data using $_POST
Hello <?php echo $_POST["name"]; ?>.
You are <?php echo $_POST["age"]; ?> years old!
GET EXAMPLE
Name:
Age:
On clicking submit the URL resembles to : http://www.mysamplesite.com/sample.php?name=jim&age=37
The sample.php file can be used for catching the form data using $_GET
Hello <?php echo $_GET["name"]; ?>.
You are <?php echo $_GET["age"]; ?> years old!
Tuesday, July 8, 2008
Monday, June 23, 2008
In how many ways we can retrieve data in the result set of mysql using php?
mysql_fetch_array - Fetch a result row as an associative array, a numeric array, or both
mysql_fetch_assoc - Fetch a result row as an associative array
mysql_fetch_object - Fetch a result row as an object
mysql_fetch_row —- Get a result row as an enumerated array
mysql_fetch_assoc - Fetch a result row as an associative array
mysql_fetch_object - Fetch a result row as an object
mysql_fetch_row —- Get a result row as an enumerated array
Sunday, June 22, 2008
How do you define a constant?
6:41 PM
No comments
Via define() directive, like define ("MYCONSTANT", 100);
How can you access a COM object from a PHP page?
6:39 PM
No comments
By utilizing the com_load and the dotnet_load respectively
you can incorporate COM objects and .NET libraries into your
PHP code, thus anytime you see "library code" in a question,
make sure you remember these two functions.
com_load — Creates a new reference to a COM component [deprecated]
Deprecated, use the OO syntax instead.
<?php
// do this
$obj = new COM($module);
// instead of this:
$obj = com_load($module);
?>
you can incorporate COM objects and .NET libraries into your
PHP code, thus anytime you see "library code" in a question,
make sure you remember these two functions.
com_load — Creates a new reference to a COM component [deprecated]
Deprecated, use the OO syntax instead.
<?php
// do this
$obj = new COM($module);
// instead of this:
$obj = com_load($module);
?>
How can we know the count/number of elements of an array?
6:37 PM
No comments
2 ways:
a) sizeof($array_name) - This function is an alias of count()
b) count($array_name) - This function returns the number of elements in an array.
Interestingly if you just pass a simple var instead of an array, count() will return 1.
a) sizeof($array_name) - This function is an alias of count()
b) count($array_name) - This function returns the number of elements in an array.
Interestingly if you just pass a simple var instead of an array, count() will return 1.
Subscribe to:
Posts (Atom)




