answersLogoWhite

0

PHP Programming

Questions about the PHP programming language; How and when to use it, implementing techniques, debugging and handling errors, and general questions about PHP itself. For questions about software made with PHP, that do not deal with the manipulating, reading, or learning about the actual code, see the Computer Software category.

845 Questions

How are placeholders used in PHP database programming?

Placeholders in an abstraction layer such as PDO in PHP allows for caching and security in database queries (they fight SQL injection).

Which parts of php are case sensitive and which are not?

Case Sensitive parts of php include:

  • Variables
  • Constants
  • Array Keys
  • Class Properties
  • Class Constants

Case Insensitive parts of php include:

  • Functions (believe it or not!)
  • Class Constructors
  • Class methods
  • Keywords and Contructs (if, else, false, true, etc.)

Explain the categories of PHP Operators in web technology?

There are arithmetic operators (+, -, %, ++, etc.), comparison operators (<, ==, >=, !=, etc.), logical operators (&&, !, , etc.), assignment operators (=, *=, %=, +=, etc.), conditional operator (?:).

The order of operations is unary (!, ++, --), multiplicative (left to right; *, /, %), additive (left to right; +, -), relational (left to right; <, <=, >, >=), equality (left to right; ==, !=), logical and (left to right; &&, and), logical or (left to right; , or), conditional (?:), assignment.

Why does it say PHP Warning fopen(file.txt) failed to open stream Permission denied in GPleskVhostswallnutclan.comhttpdocstest.php on line 5 on plex when it doesn't give me the error on wamp server co?

Your PHP file does not have the required permissions to open that file with write capabilities. Try Granting higher permissions (777, etc) to the PHP file itself, and / or GPleskVhostswallnutclan.comhttpdocstest.php.

What are the similarities between php statement and javascript statement?

PHP and JavaScript are quite different, given that PHP is server-side and JS is (typically) client-side. However, with Node.JS -for example- you can now also use JS on the server-side.
They are both interpreted languages (scripts), they are both incredibly popular languages running a huge amount of the internet, and they are both some of the simplest languages to start out in.

Which character is usually used to terminate PHP statement?

A semicolon ( ; ) is often used at the end of an expression to conclude it and hopefully the line as well. If this is in reference to a block of code, the answer could be a closing curly bracket ( } ). If this is in reference to all of your PHP in a given area, a closing tag would be used ( ?>).

What is the use of php in seo?

SEO (Search Engine Optimization) is used for webpages be it php, asp.net or perl. Not the other way round.

What character allows you to concatenate strings in PHP?

To concatenate strings in PHP, you use the . (dot) character.

For example:

$str = "String1" . "String2";

How do you write a program to print numbers from star one and next line star two in php?

Try the triangle program on a search engine. Replace numbers with stars and that should do the trick

What is xampp?

One of the web servers for php which supports coding in PERL programming

How validate and retrieve data from database?

It is better to validate the data going into the database for errors rather then data coming out. The data to be retrieved can be done using the $_REQUEST or mysql_fetch_array or PDO statements. I am giving 2 simple examples

// The connection string or function here to connect to database

// Put the name of your database in place of db_name

mysql_select_db("db_name");

// Enter the name of table in place of table_name

$query = mysql_query("SELECT * FROM table_name");

while($fetch = mysql_fetch_array($query))

{

// add your table column names in the square blocks

echo $fetch['Name']."
";

echo $fetch['email']."
";

}

?>

If you want a particular data that can be obtained by using the where clause

The ID would come from user input

$data = $_REQUEST['ID'];

// Enter the name of table in place of table_name

$query = mysql_query("SELECT * FROM table_name WHERE ID='$data'");

while($fetch = mysql_fetch_array($query))

{

// add your table column names in the square blocks

echo $fetch['Name']."
";

echo $fetch['email']."
";

}

?>

What files can contain PHP?

PHP code can be stored in any kind of file -- the extension of the file indicates what said file contains, but may not necessarily be true.

The "php" extension is used to indicate PHP which is meant for execution and presentation.

How do decrypt the password in php?

If the encryption is applied using md5, decrypting is normally impossible (emphasizes on normally).

What is PHP and PHPMyAdmin?

PHP is a server-side scripting language that can be used to dynamically generate the content of web sites served up to a client. It can also be used for local shell scripting.

PHPMyAdmin is a PHP based web interface for managing MySQL databases.

How do you use a function with a button in PHP?

A simple function call

<html>

<body>

<?php

if(isset($_POST['button']))

{

setValue(); // Function is called

}

function setValue()

{

echo "<br>The button property to call PHP function works";

// Your code here

}

?>

<input type="submit" name="button" onclick=<?php $_SERVER['PHP_SELF']; ?> />

</body>

</head>

What do you use to separate multiple arguments that are passes to a function?

Commas.

The call looks like:

$returnValue = ourCrazyFunction($arg1, $arg2, $arg3);

What is the first step to use in detecting data type mismatch errors?

Better if you use javascript or another scripting language to analyse what is sent to the server in the first place. Most of the browsers support javascript.

Suppose there is an input type of text of the simple html form

Name:

Age :

// The button below makes sure that client side validation is done otherwise it doesn't send data to servers

// Here the "return checkData()" forces the client-side validation to occur before sending it to server

// The neat little code tells if javascript is enabled/disabled in browser

Most of things would be easy this way but alas things aren't so easy. You also need to validate data on the server side using echo statements & control loops before finally posting data in mysql table

Where is php applied?

Primarily it is applied for creating web applications and websites which deal with client-server model. Use mysql db with php and you could build a three tire architecture. Couple of big website like Facebook do use php.

What are semantics in PHP?

PHP is related with HTML. HTML can be included into PHP script as well as PHP script can be included into HTML code. PHP begins and ends with <?php ?>. PHP is mix of few languages so semantics is mixed too.

What is the actual meaning of PHP?

It is a programming language.

PHP is short for "PHP: Hypertext Preprocessor"

Whose is php?

PHP was originally developed in 1995 by Rasmus Lerdorf. In 1997 it became much more similar to the PHP we know today when the parser was rewritten by Zeev Suraski and Andi Gutmans. It is now maintained by a large community of developers, with several key figures leading the way.

What is isset in php?

isset( $var ) is a PHP function which returns TRUE or FALSE depending on whether a specified $var has been assigned to any value (or, initialized).