PHP Developer

  Home  Computer Programming  PHP Developer


“PHP Developer Frequently Asked Questions by expert members with experience in PHP Developer. These questions and answers will help you strengthen your technical skills, prepare for the new job test and quickly revise the concepts”



57 PHP Developer Questions And Answers

41⟩ How to send mail using JavaScript?

No. There is no way to send emails directly using JavaScript.

But you can use JavaScript to execute a client side email program send the email using the "mailto" code. Here is an example:

function myfunction(form)

{

tdata=document.myform.tbox1.value;

location="mailto:mailid@domain.com?subject=...";

return true;

}

 155 views

42⟩ How to create table using PHP?

If you want to create a table, you can run the CREATE TABLE statement as shown in the following sample script:

<?php

include "mysql_connection.php";

$sql = "CREATE TABLE ggl_links ("

. " id INTEGER NOT NULL"

. ", url VARCHAR(80) NOT NULL"

. ", notes VARCHAR(1024)"

. ", counts INTEGER"

. ", time TIMESTAMP DEFAULT sysdate()"

. ")";

if (mysql_query($sql, $con)) {

print("Table ggl_links created.n");

} else {

print("Table creation failed.n");

}

mysql_close($con);

?>

Remember that mysql_query() returns TRUE/FALSE on CREATE statements. If you run this script, you will get something like this:

Table ggl_links created.

 140 views

44⟩ How to encrypt the username and password using PHP?

You can encrypt a password with the following Mysql>SET PASSWORD=PASSWORD("Password");

Or:

You can use the MySQL PASSWORD() function to encrypt username and password. For example,

INSERT into user (password, ...) VALUES (PASSWORD($password")), ...);

 167 views

49⟩ List the purpose of the following files having extensions frm, myd, and myi? What these files contain?

In MySQL, the default table type is MyISAM.

Each MyISAM table is stored on disk in three files. The files have names that begin with the table name and have an extension to indicate the file type.

The '.frm' file stores the table definition.

The data file has a '.MYD' (MYData) extension.

The index file has a '.MYI' (MYIndex) extension,

 163 views

50⟩ What are php validate filters?

FILTER_VALIDATE_BOOLEAN

Returns TRUE for "1", "true", "on" and "yes". Returns FALSE otherwise.

FILTER_VALIDATE_EMAIL

Validates value as e-mail.

FILTER_VALIDATE_FLOAT

Validates value as float.

FILTER_VALIDATE_INT

Validates value as integer optionally from the specified range.

FILTER_VALIDATE_IP

Validates value as IP address, optionally only IPv4 or IPv6 or not from private or reserved ranges.

FILTER_VALIDATE_REGEXP

Validates value against regexp, a Perl-compatible regular expression.

FILTER_VALIDATE_URL

Validates value as URL, optionally with required components.

 133 views

52⟩ Can you please explain the difference between $message and $$message?

They are both variables. But $message is a variable with a fixed name. $$message is a variable who's name is stored in $message. For example, if $message contains "var", $$message is the same as $var.

$message is a simple variable whereas $$message is a reference variable. Example:

$user = 'bob'

is equivalent to

$holder = 'user';

$$holder = 'bob';

 147 views

53⟩ How you can 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 GlobalGuideLine.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>");

?>

 140 views

55⟩ What is PEAR in PHP?

PEAR is the next revolution in PHP. This repository is bringing higher level programming to PHP. PEAR is a framework and distribution system for reusable PHP components. It eases installation by bringing an automated wizard, and packing the strength and experience of PHP users into a nicely organised OOP library. PEAR also provides a command-line interface that can be used to automatically install "packages"

 128 views

56⟩ Described PHP?

The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications.

 160 views

57⟩ Described session in PHP?

A session is a logical object created by the PHP engine to allow you to preserve data across subsequent HTTP requests.

There is only one session object available to your PHP scripts at any time. Data saved to the session by a script can be retrieved by the same script or another script when requested from the same visitor.

Sessions are commonly used to store temporary data to allow multiple PHP pages to offer a complete functional transaction for the same visitor.

 149 views