PHP || old paper solution 2016

4th semester

Group A

1.List out the advantage of using PHP

  • PHP runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
  • PHP is compatible with almost all servers used today (Apache, IIS, etc.)
  • PHP supports a wide range of databases
  • PHP is free. Download it from the official PHP resource: php.net
  • PHP is easy to learn and runs efficiently on the server side

2. What is use of identical operator(===)

  • The PHP assignment operators are used with numeric values to write a value to a variable. The basic assignment operator in PHP is “=”. It means that the left operand gets set to the value of the assignment expression on the right.

4. Write syntax of foreach loop

 

5. How a function is declared using default values for its arguments Function arguments Information may be passed to functions via the argument list, which is a comma-delimited list of expressions. The arguments are evaluated from left to right. PHP supports passing arguments by value (the default), passing by reference, and default argument values.
6. “validations should be performed on both the client and server side”. Why
validations should be performed on client side in order to validate data and validations should be performed on server side in order to check user.
7. Define server variable HTTP_USER_AGENT with an example The user agent string is a text that the browsers themselves send to the web server to identify themselves, so that websites can send different content based on the browser or based on browser compatibility.
8. What are the advantage of using PEAR over PHP built in functions to work with the database .
The advantage of using PEAR over PHP built in functions to work with the database is it can be used in any database
9. How to display the current date in web page using PHP statement
Tthe current date can be display using date function in web page using PHP statement
10. What is use of mysql_fetch_assoc() function The mysql_fetch_assoc() used to retrieve a row of data as an associative array from a MySQL result handle. … Refers to the resource return by a valid mysql query (calling by mysql_query() function). … An array containing one row of data, or FALSE if there are no more rows


Group B

11.Write a PHP program to create a web form that contains a textbox for name, and checkboxes for hobbies. When a form is submitted, check a name is entered and at least one of the hobbies is selected.

12.Write a PHP program to display the contents of a database. Make your own assumptions about database.

13. Write a PHP function that makes three arguments: principle, rate and time and returns the calculated interest. Make all the required validation to calculate the interest. 

14. What is file? Write a program to write value taken from user to a file. 

15. Write a PHP program to create a multidimensional array that holds the cities of districts in Kathmandu valley such as Kathmandu(Newroad , Durbar Marg, Thamel) Lalitpur(Patan, Jawalakhel, Kupandole) Bhaktpur(Durbar Square, suryabinayak). Then display the contents of array. 

Group C
1.Explain the importance of default value in a form with example.
The importance of default value is that Default values will make  easier  for users to complete  forms and clear when a user begins typing in the field .These default values are not saved with the form submission. Default values will be used when a new entry is created or when a field is conditionally shown. Default values will NOT replace submitted values when you edit an entry, even if the submitted value is empty. When you redisplay a form because of an error, it is helpful to preserve any information that a user has already entered.
For example

2.What is session variable? How are session variable handled in php? Explain with example.

Session variable are special variables that exist only while the users session with application is active.Session variable handled by storing user information to be used across multiple pages. Session variable handled in php by using the following example.

Leave a Reply

Your email address will not be published. Required fields are marked *