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:

What is the difference between $argv and $argc? Give example?

Answer

To pass the information into the script from outside, help can be taken from the PHP CLI (Command line interface) method. Suppose addition of two numbers has to be passed to PHP then it can be passed like this on the command line:


php add.php 2 3


Here the script name is add.php, and 2 and 3 are the numbers that has to be added by the script. These numbers are available inside the script in an array called $argv. This array contains all the information on the command line; the statement is stored as follows:


$argv[0]=add.php


$argv[1]=2


$argv[2]=3


So, $argv always contains at least one element — the script name.


Then, in your script, you can use the following statements:


$sum = $argv[1] + $argv[2];


echo $sum;


$argc is a variable that stores the numbers of elements in $argv. $argc is equal to at least 1, which is saved for the name of the script. Example is $argc=3 using the above statements.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 5582
Q:

What is the use of $_Server and $_Env?

Answer

$_SERVER and $_ENV arrays contain different information. The information depends on the server and operating system being used. Most of the information can be seen of an array for a particular server and operating system. The syntax is as follows:


foreach($_SERVER as $key =>$value)


{ echo “Key=$key, Value=$value\n”; }

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

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

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

0 2239
Q:

What is the difference between PHP and JavaScript?

Answer

The difference lies with the execution of the languages. PHP is server side scripting language, which means that it can’t interact directly with the user. Whereas, JavaScript is client side scripting language, that is used to interact directly with the user.


 

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 2049
Q:

Why many companies are switching their current business language to PHP? Where PHP basically used?

Answer

PHP is rapidly gaining the popularity and many companies are switching their current language for this language. PHP is a server side scripting language. PHP executes the instructions on the server itself. Server is a computer where the web site is located. PHP is used to create dynamic pages and provides faster execution of the instructions.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 1673
Q:

How to use HTTP Headers inside PHP? Write the statement through which it can be added?

Answer

HTTP headers can be used in PHP by redirection which is written as:


<?header('Location: https://www.php.net')?>


The headers can be added to HTTP response in PHP using the header(). The response headers are sent before any actual response being sent. The HTTP headers have to be sent before taking the output of any data. The statement above gets included at the top of the script.


 

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

1 17750
Q:

What is MIME?

Answer

MIME - Multi-purpose Internet Mail Extensions. 


MIME types represents a standard way of classifying file types over Internet. 


Web servers and browsers have a list of MIME types, which facilitates files transfer of the same type in the same way, irrespective of operating system they are working in.


A MIME type has two parts: a type and a subtype. They are separated by a slash (/). 


MIME type for Microsoft Word files is application and the subtype is msword, i.e. application/msword.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP - Technology

0 1995