2
Q:

PHP allows you to send emails directly from a script.

php allows you to send emails directly from a script

 

A) TRUE B) FALSE

Answer:   A) TRUE



Explanation:

The mail() function allows you to send emails directly from a script.

 

Q:

Explain the different types of errors in PHP.

Answer

Notices, Warnings and Fatal errors are the types of errors in PHP


Notices: 


Notices represents non-critical errors, i.e. accessing a variable that has not yet been defined. By default, such errors are not displayed to the user at all but whenever required, you can change this default behavior.


Warnings: 


Warnings are more serious errors but they do not result in script termination. i.e calling include() a file which does not exist. By default, these errors are displayed to the user.


Fatal errors: 


Fatal errors are critical errors i.e. calling a non-existent function or class. These errors cause the immediate termination of the script.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 2207
Q:

$message vs $$message in PHP?

Answer

$message is a variable with a fixed name. $$message is a variable whose name is stored in $message. 


If $message contains "var", $$message is the same as $var.


 

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 4786
Q:

Echo vs print statement

Answer

echo() and print() are language constructs in PHP, both are used to output strings. The speed of both statements is almost the same.


echo() can take multiple expressions whereas print cannot take multiple expressions.


Print return true or false based on success or failure whereas echo doesn't return true or false.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 1808
Q:

What is PEAR in php?

Answer

PEAR(PHP Extension and Application Repository) is a framework and repository for reusable PHP components. PEAR is a code repository containing all kinds of php code snippets and libraries. 


PEAR also offers a command-line interface that can be used to automatically install "packages".

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 2165
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 - Technology

0 1839
Q:

What is the functionality of md5 function in PHP?

Answer

Calculate the md5 hash of a string. The hash is a 32-character hexadecimal number. I use it to generate keys which I use to identify users etc. If I add random no techniques to it the md5 generated now will be totally different for the same string I am using.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 1701
Q:

How can we find the number of rows in a result set using PHP?

Answer

$result = mysql_query($sql, $db_link);
$num_rows = mysql_num_rows($result);
echo "$num_rows rows found";

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 2367
Q:

How can I retrieve values from one database server and store them in other database server using PHP?

Answer

we can always fetch from one database and rewrite to another. Here is a nice solution of it.$db1 = mysql_connect("host","user","pwd")
mysql_select_db("db1", $db1);
$res1 = mysql_query("query",$db1);$db2 = mysql_connect("host","user","pwd")
mysql_select_db("db2", $db2);
$res2 = mysql_query("query",$db2);At this point you can only fetch records from you previous ResultSet, i.e $res1 – But you cannot execute new query in $db1, even if you supply the link as because the link was overwritten by the new db.so at this point the following script will fail
$res3 = mysql_query("query",$db1); //this will failSo how to solve that?

take a look below.
$db1 = mysql_connect("host","user","pwd")
mysql_select_db("db1", $db1);
$res1 = mysql_query("query",$db1);

$db2 = mysql_connect("host","user","pwd", true)
mysql_select_db("db2", $db2);
$res2 = mysql_query("query",$db2);

So mysql_connect has another optional boolean parameter which indicates whether a link will be created or not, as we connect to the
$db2 with this optional parameter set to 'true', so both link will remain live.

Now the following query will execute successfully.
$res3 = mysql_query("query",$db1);

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

1 10018