PHP Questions

Q:

What’s the difference between htmlentities() and htmlspecialchars()?

Answer

Htmlentities() converts all applicable characters to HTML entities. While htmlspecialcharacter()converts special characters to HTML entities. This means htmlentities( ) will check for non English language characters, such as French accents, the German umlaut, etc.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

3 2224
Q:

How to set cookies in PHP?

Answer

The function setcookie() is used to define a cookie that is to be sent along with HTTP headers. The cookie must be sent prior to any output from the script as is the protocol restriction. After setting the cookies, they can be used when the next page is loaded by using $_COOKIE or $HTTP_COOKIE_VARS arrays.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 2199
Q:

What is Constructors and Destructors?

Answer

CONSTRUCTOR : PHP allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.

DESTRUCTORS : PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as all references to a particular object are removed or when the object is explicitly destroyed or in any order in shutdown sequence.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 2197
Q:

Which function would you use to insert a record into a database?

Answer

The dba_insert() function adds a record to a database.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 2192
Q:

Are objects passed by value or by reference?

Answer Everything is passed by value.
Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 2187
Q:

What is the use of super-global arrays in PHP?

Answer

Super global arrays are the built in arrays that can be used anywhere. They are also called as auto-global as they can be used inside a function as well. The arrays with the longs names such as $HTTP_SERVER_VARS, must be made global before they can be used in an array. This $HTTP_SERVER_VARS check your php.ini setting for long arrays.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 2176
Q:

What is PHP?

Answer

PHP: Hypertext Preprocessor is open source server-side scripting language that is widely used for web development. PHP scripts are executed on the server. PHP allows writing dynamically generated web pages efficiently and quickly. The syntax is mostly borrowed from C, Java and perl. PHP is free to download and use.


 

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 2141
Q:

What are the differences between mysql_fetch_array(), mysql_fetch_object(), mysql_fetch_row()?

Answer

mysql_fetch_array:
Fetch a result row as an associative array and a numeric array.

mysql_fetch_object:
Returns an object with properties that correspond to the fetched row and moves the internal data pointer ahead. Returns an object with properties that correspond to the fetched row, or FALSE if there are no more rows.

mysql_fetch_row():
Fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 2092