PHP Questions

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 & Explanation Answer: A) TRUE

Explanation:

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


 

Report Error

View Answer Workspace Report Error Discuss

Subject: PHP
Exam Prep: Bank Exams
Job Role: IT Trainer , Project Manager , Software Architect

2 2342
Q:

If the variable $a is equal to 5 and variable $b is equal to character a, what’s the value of $$b?

Answer 100, it’s a reference to existing variable.
Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 2329
Q:

Explain how to send large amounts of emails with php.

Answer

The mail() function of PHP is quite robust for sending bulk emails. A SMTP server can also be directly used from the script. PHPmailer class can be used for sending emails.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 2325
Q:

How can we increase the execution time of a php script?

Answer

By the use of void set_time_limit(int seconds)


Set the number of seconds a script is allowed to run. If this is reached, the script returns a fatal error. The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php.ini. If seconds is set to zero, no time limit is imposed.


When called, set_time_limit() restarts the timeout counter from zero. In other words, if the timeout is the default 30 seconds, and 25 seconds into script execution a call such as set_time_limit(20) is made, the script will run for a total of 45 seconds before timing out.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 2311
Q:

What Is a Session in PHP?

Answer

A PHP Session persist the user information to be used later. For example, user name, password, shopping item details. The session is temporary and will be removed soon after the user has left the web site. The session can be persisted for long term usage on databases like MySQL. Each session is identified by a unique Id number for every visitor. The first step to use PHP session is to start the session. The starting session must precede the operations like HTML or the other.


The statement session_start() starts the PHP session and registers the user’s information on the server.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 2279
Q:

How to open a file?

Answer

<?php
$file = fopen("file.txt","r");
?>

Report Error

View answer Workspace Report Error Discuss

Subject: PHP

0 2278
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

0 2263
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

0 2245