If The Variable $a Is Equal To 5 And Variable $b Is Equal To Character A, What's The Value Of $$b?
5, it’s a reference to existing variable.
How To Protect Special Characters In Query String?
If you want to include special characters like spaces in the query string, you need to protect them by applying the urlencode() translation function. The script below shows how to use urlencode():
<?php
print("<html>");
print("<p>Please click the links below"
." to submit comments about FYICenter.com:</p>");
$comment = 'I want to say: "It\'s a good site! :->"';
$comment = urlencode($comment);
print("<p>"
."<a href=\"processing_forms.php?name=Guest&comment=$comment\">"
."It's an excellent site!</a></p>");
$comment = 'This visitor said: "It\'s an average site! :-("';
$comment = urlencode($comment);
print("<p>"
.'<a href="processing_forms.php?'.$comment.'">'
."It's an average site.</a></p>");
print("</html>");
?>
Are Objects Passed By Value Or By Reference?
Everything is passed by value.
What Are The Differences Between Drop A Table And Truncate A Table?
DROP TABLE table_name - This will delete the table and its data.
TRUNCATE TABLE table_name - This will delete the data of the table, but not the table definition.
What Is The Difference Between Characters \023 And \x23?
The first one is octal 23, the second is hex 23.
How Can We Submit Form Without A Submit Button?
We can use a simple JavaScript code linked to an event trigger of any form field. In the JavaScript code, we can call the document.form.submit() function to submit the form. For example: <input type=button value="Save" onClick="document.form.submit()">.
How Can We Create A Database Using Php And Mysql?
We can create MySQL database with the use of mysql_create_db($databaseName) to create a database.
How Many Ways We Can Retrieve The Date In Result Set Of Mysql Using Php?
As individual objects so single record or as a set or arrays.
How Many Ways Can We Get The Value Of Current Session Id?
session_id() returns the session id for the current session.
Can We Use Include ("abc.php") Two Times In A Php Page "makeit.php"?
Yes.
What's The Difference Between Include And Require?
It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
Explain The Ternary Conditional Operator In Php?
Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed.
What Type Of Headers Have To Be Added In The Mail Function To Attach A File?
$boundary = '--' . md5( uniqid ( rand() ) );
$headers = "From: \"Me\"\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";
List Out Different Arguments In Php Header Function?
void header ( string string [, bool replace [, int http_response_code]]).
What Are The Different Functions In Sorting An Array?
Sorting functions in PHP:
asort()
arsort()
ksort()
krsort()
uksort()
sort()
natsort()
rsort()
How Can We Know The Count / Number Of Elements Of An Array?
2 ways:
sizeof($array) - This function is an alias of count().
count($urarray) - This function returns the number of elements in an array. Interestingly if you just pass a simple var instead of an array, count() will return 1.
How Many Ways I Can Redirect A Php Page?
Here are the possible ways of php page redirection.
1. Using Java script:
'; echo 'window.location.href="'.$filename.'";'; echo ''; echo ''; echo ''; echo ''; } }
redirect
2. Using php function: header
How Many Ways We Can Pass The Variable Through The Navigation Between The Pages?
At least 3 ways:
1. Put the variable into session in the first page, and get it back from session in the next page.
2. Put the variable into cookie in the first page, and get it back from the cookie in the next page.
3. Put the variable into a hidden form field, and get it back from the form in the next page.
What Is The Maximum Length Of A Table Name, A Database Name, Or A Field Name In Mysql?
Database name: 64 characters
Table name: 64 characters
Column name: 64 characters
How Many Values Can The Set Function Of Mysql Take?
MySQL SET function can take zero or more values, but at the maximum it can take 64 values.
What Are The Other Commands To Know The Structure Of A Table Using Mysql Commands Except Explain Command?
DESCRIBE table_name;
How Can We Find The Number Of Rows In A Table Using Mysql?
Use this for MySQL
SELECT COUNT(*) FROM table_name;
What's The Difference Between Htmlentities() And Htmlspecialchars()?
htmlspecialchars only takes care of <, >, single quote ‘, double quote " and ampersand.
htmlentities translates all occurrences of character sequences that have different meaning in HTML.
How To Store The Uploaded File To The Final Location?
move_uploaded_file ( string filename, string destination)
This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.
If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE.
If filename is a valid upload file, but cannot be moved for some reason, no action will occur, and move_uploaded_file() will return FALSE. Additionally, a warning will be issued.
What Is The Difference Between Reply-to And Return-path In The Headers Of A Mail Function?
Reply-to : Reply-to is where to delivery the reply of the mail.
Return-path : Return path is when there is a mail delivery failure occurs then where to delivery the failure notification.
So If Md5() Generates The Most Secure Hash, Why Would You Ever Use The Less Secure Crc32() And Sha1()?
Crypto usage in PHP is simple, but that doesn’t mean it’s free. First off, depending on the data that you’re encrypting, you might have reasons to store a 32-bit value in the database instead of the 160-bit value to save on space. Second, the more secure the crypto is, the longer is the computation time to deliver the hash value. A high volume site might be significantly slowed down, if frequent md5() generation is required.
How Can We Destroy The Session, How Can We Unset The Variable Of A Session?
session_unregister() - Unregister a global variable from the current session.
session_unset() - Free all session variables.
What Changes I Have To Do In Php.ini File For File Uploading?
Make the following line uncomment like:
; Whether to allow HTTP file uploads.
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = C:\apache2triad\temp
; Maximum allowed size for uploaded files.
upload_max_filesize = 2M
What's The Difference Between Md5(), Crc32() And Sha1() Crypto On Php?
The major difference is the length of the hash generated. CRC32 is, evidently, 32 bits, while sha1() returns a 128 bit value, and md5() returns a 160 bit value. This is important when avoiding collisions.
How Can We Find The Number Of Rows In A Result Set Using Php?
Here is how can you find the number of rows in a result set in PHP:
$result = mysql_query($any_valid_sql, $database_link);
$num_rows = mysql_num_rows($result);
echo "$num_rows rows found";
What Is The Default Session Time In Php And How Can I Change It?
The default session time in php is until closing of browser.
How Many Ways We Can We Find The Current Date Using Mysql?
SELECT CURDATE();
SELECT CURRENT_DATE();
SELECT CURTIME();
SELECT CURRENT_TIME();
5, it’s a reference to existing variable.
How To Protect Special Characters In Query String?
If you want to include special characters like spaces in the query string, you need to protect them by applying the urlencode() translation function. The script below shows how to use urlencode():
<?php
print("<html>");
print("<p>Please click the links below"
." to submit comments about FYICenter.com:</p>");
$comment = 'I want to say: "It\'s a good site! :->"';
$comment = urlencode($comment);
print("<p>"
."<a href=\"processing_forms.php?name=Guest&comment=$comment\">"
."It's an excellent site!</a></p>");
$comment = 'This visitor said: "It\'s an average site! :-("';
$comment = urlencode($comment);
print("<p>"
.'<a href="processing_forms.php?'.$comment.'">'
."It's an average site.</a></p>");
print("</html>");
?>
Are Objects Passed By Value Or By Reference?
Everything is passed by value.
What Are The Differences Between Drop A Table And Truncate A Table?
DROP TABLE table_name - This will delete the table and its data.
TRUNCATE TABLE table_name - This will delete the data of the table, but not the table definition.
What Is The Difference Between Characters \023 And \x23?
The first one is octal 23, the second is hex 23.
How Can We Submit Form Without A Submit Button?
We can use a simple JavaScript code linked to an event trigger of any form field. In the JavaScript code, we can call the document.form.submit() function to submit the form. For example: <input type=button value="Save" onClick="document.form.submit()">.
How Can We Create A Database Using Php And Mysql?
We can create MySQL database with the use of mysql_create_db($databaseName) to create a database.
How Many Ways We Can Retrieve The Date In Result Set Of Mysql Using Php?
As individual objects so single record or as a set or arrays.
How Many Ways Can We Get The Value Of Current Session Id?
session_id() returns the session id for the current session.
Huawei Most Frequently Asked Latest PHP Interview Questions Answers |
Can We Use Include ("abc.php") Two Times In A Php Page "makeit.php"?
Yes.
What's The Difference Between Include And Require?
It’s how they handle failures. If the file is not found by require(), it will cause a fatal error and halt the execution of the script. If the file is not found by include(), a warning will be issued, but execution will continue.
Explain The Ternary Conditional Operator In Php?
Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed.
What Type Of Headers Have To Be Added In The Mail Function To Attach A File?
$boundary = '--' . md5( uniqid ( rand() ) );
$headers = "From: \"Me\"\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"";
List Out Different Arguments In Php Header Function?
void header ( string string [, bool replace [, int http_response_code]]).
What Are The Different Functions In Sorting An Array?
Sorting functions in PHP:
asort()
arsort()
ksort()
krsort()
uksort()
sort()
natsort()
rsort()
How Can We Know The Count / Number Of Elements Of An Array?
2 ways:
sizeof($array) - This function is an alias of count().
count($urarray) - This function returns the number of elements in an array. Interestingly if you just pass a simple var instead of an array, count() will return 1.
How Many Ways I Can Redirect A Php Page?
Here are the possible ways of php page redirection.
1. Using Java script:
'; echo 'window.location.href="'.$filename.'";'; echo ''; echo ''; echo ''; echo ''; } }
redirect
2. Using php function: header
How Many Ways We Can Pass The Variable Through The Navigation Between The Pages?
At least 3 ways:
1. Put the variable into session in the first page, and get it back from session in the next page.
2. Put the variable into cookie in the first page, and get it back from the cookie in the next page.
3. Put the variable into a hidden form field, and get it back from the form in the next page.
What Is The Maximum Length Of A Table Name, A Database Name, Or A Field Name In Mysql?
Database name: 64 characters
Table name: 64 characters
Column name: 64 characters
How Many Values Can The Set Function Of Mysql Take?
MySQL SET function can take zero or more values, but at the maximum it can take 64 values.
What Are The Other Commands To Know The Structure Of A Table Using Mysql Commands Except Explain Command?
DESCRIBE table_name;
How Can We Find The Number Of Rows In A Table Using Mysql?
Use this for MySQL
SELECT COUNT(*) FROM table_name;
What's The Difference Between Htmlentities() And Htmlspecialchars()?
htmlspecialchars only takes care of <, >, single quote ‘, double quote " and ampersand.
htmlentities translates all occurrences of character sequences that have different meaning in HTML.
How To Store The Uploaded File To The Final Location?
move_uploaded_file ( string filename, string destination)
This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.
If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE.
If filename is a valid upload file, but cannot be moved for some reason, no action will occur, and move_uploaded_file() will return FALSE. Additionally, a warning will be issued.
What Is The Difference Between Reply-to And Return-path In The Headers Of A Mail Function?
Reply-to : Reply-to is where to delivery the reply of the mail.
Return-path : Return path is when there is a mail delivery failure occurs then where to delivery the failure notification.
So If Md5() Generates The Most Secure Hash, Why Would You Ever Use The Less Secure Crc32() And Sha1()?
Crypto usage in PHP is simple, but that doesn’t mean it’s free. First off, depending on the data that you’re encrypting, you might have reasons to store a 32-bit value in the database instead of the 160-bit value to save on space. Second, the more secure the crypto is, the longer is the computation time to deliver the hash value. A high volume site might be significantly slowed down, if frequent md5() generation is required.
How Can We Destroy The Session, How Can We Unset The Variable Of A Session?
session_unregister() - Unregister a global variable from the current session.
session_unset() - Free all session variables.
What Changes I Have To Do In Php.ini File For File Uploading?
Make the following line uncomment like:
; Whether to allow HTTP file uploads.
file_uploads = On
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = C:\apache2triad\temp
; Maximum allowed size for uploaded files.
upload_max_filesize = 2M
What's The Difference Between Md5(), Crc32() And Sha1() Crypto On Php?
The major difference is the length of the hash generated. CRC32 is, evidently, 32 bits, while sha1() returns a 128 bit value, and md5() returns a 160 bit value. This is important when avoiding collisions.
How Can We Find The Number Of Rows In A Result Set Using Php?
Here is how can you find the number of rows in a result set in PHP:
$result = mysql_query($any_valid_sql, $database_link);
$num_rows = mysql_num_rows($result);
echo "$num_rows rows found";
What Is The Default Session Time In Php And How Can I Change It?
The default session time in php is until closing of browser.
How Many Ways We Can We Find The Current Date Using Mysql?
SELECT CURDATE();
SELECT CURRENT_DATE();
SELECT CURTIME();
SELECT CURRENT_TIME();
Post a Comment