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 do you write 55555 4444 333 22 1 in php?

This is one of possible solutions:

for ($i=5; $i>0; $i--)

{

for ($j=$i; $j>0; $j--) {

echo $i;

}

echo " ";

}

?>

How you write log out code in php?

if you're using a session, you can simply use the unset function:

unset($_SESSION);

session_unset();

session_destroy();

good luck !

Who is the best PHP programmer of all time?

Thankfully, there was no stupid competition to determine this outcome. Well it is better to concentrate on Good Coding Practices and various Software Development Models rather then to worry about who is the best and who is the worst

Is php static or not?

PHP is a dynamic, server-side, web scripting language. It is capable of making connections to a database, and storing information to that database as well as reading queries form the DB. This means that PHP allows for the creation of dynamic web pages that change over time, as opposed to static HTML pages that are rewritten once and do not change without intervention by the page owner.

What is CMS and its Type in PHP?

CMS is a Content Management System, Some types of CMS's that are written in PHP would be WordPress, Drupal, Joomla.

Is this what you were asking?

Is tomcat server use for php?

In normal circumstances only apache server supports php scripts. There can be some tweaking done in tomcat to support php

What is a parse error in php?

Parse error in PHP means that your script is invalid - it is not compliant with the programming language specification. After parse error script is no longer executed.

What is a php session?

A PHP session is a concept where specific variables (and their respective values) are carried throughout a user's viewing of a PHP-driven website.

These sessions can be initialized and continued using the session_start() function. The session values are stored in the $_SESSION global variable. For more information, see the php.net documentation of session functions.

What are the differences between PHP and Pascal?

PHP is:

-a server-side scripting language originally designed for web programming

-younger (first appeared in 1995) and more used than Pascal

-language that interpret it's code (not compile)

Pascal is:

-procedural programming language (PHP 5.3 also implemented Object oriented programming)

-language that compiles it's code into binary file

-published in 1970 by Niklaus Wirth

-used mainly for educational purposes in these days

Source: wikipedia.org

What is the name of php language?

From Wikipedia: PHP originally stood for "Personal Home Page", it is now said to stand for "PHP: Hypertext Preprocessor", a recursive acronym.

https://en.wikipedia.org/wiki/Php

How do you use class and object in php?

I believe the best way is to show you an example:

class Car{

private $gas=0;

private __construct(){

$gas=500; //when you create an object your gas tank is automatically filled with 500 gas for a start

}

public function fill_the_tank($amount){

$gas=$amoung;

}

public function get_gas(){

return $gas;

}

}

$ferrari = new Car;

echo $ferrari->get_gas(); //prints out "500"

$ferrari->get_gas(); //prints out nothing, but also doesn't end up in error

$ferrari->fill_the_tank(100);

echo $ferrari->get_gas() //prints out "600"

What is new in PHP?

PHP is a recursive acronym for "PHP: Hypertext Preprocessor" created by The PHP Group. PHP is a widely used server-side scripting language and the general purpose of PHP is to create dynamic Web Pages. For more information, visit the PHP website.

Why PHP function is called when page is loaded?

There must be a statement in the file which calls the function

What is operator in php?

An operator merges two different values and outputs a new expression based on the inputted values.

What are the syntax and semantics of the include construct?

The PHP syntax and semantics are the format (syntax) and the related meanings (semantics) of the text and symbols in the PHP programming language. They form a set of rules that define how a PHP program can be written and interpreted. PHP is a procedural and object-oriented language (OOL) for coding webpage markup text to be transformed into HTML format on computerized devices. In later releases, PHP generates some code to be run by the Zend Engine, beyond using just HTML markup text. The syntax of PHP changed to include OOL keywords in versions PHP 3 and PHP 5.

What are the four scalar types of PHP?

Four scalar types of PHP

String

String is used for binary data. This can be text, content of an image file etc.

$today = 'hey how are you';

Int

For numeric values, Int is used. Int can contain a positive or a negative number.

$total = 20000000;

$temperature = -14 ;

Float

Float is used for numbers that have a fractional component. Float can also contain positive or negative values.

$length = 145.78;

$growthRate = -5.216;

Sometimes name Double is used for Float values.

Boolean

Boolean is used for values that are either true or false. You would often see Boolean values in conditional statements.

if (($age > 12) && ($age < 20)) {

$teenage = true;

} else {

$teenage = false;

}

//Some content goes here

if ($teenage) {

}

How to display a variable in PHP using echo or print statements?

displaying a variable in php using echo statement?

<?php

$name="ram"; //declaring and defining the variable

echo "$name"; //printing the variable using echo command

?>

How to make constant name case insensitive in PHP?

Generally, constant names are case sensitive in PHP.

But... you can do a trick. If you will be consistent and all constant name will be defines as uppercase, you can access them using a combination of constant() and strtoupper() functions. Look at this example:

?php

define(MY_CONSTANT, "HELLO");

echo constant(strtoupper(my_constant));

echo "
";

echo constant(strtoupper(My_Constant));

echo "
";

echo constant(strtoupper(my_CONSTANT));

?>

What is the Use of a double dollar sign in php?

A double dollar sign in php makes a variable with a name equal to the value of the original variable. It works like this:

$var = "keith";

$$var = "palmer";

print ($keith);
// The output is: palmer

How to display listbox selected value in a texbox?

Here's the code:

<head>

<title>List Box Value in Text Box</title>

<script type="text/javascript" language="javascript">

function getValue(string)

{

document.getElementById("text").value = string;

}

</script>

</head>

<body>

<form name="form1">

<h2>Get Selected Value</h2>

<select name="select" size="5" onclick="getValue(this.value)">

<option value="apple">Apple</option>

<option value="tangerines">Tangerines</option>

<option value="banana">Banana</option>

<option value="grapes">Grapes</option>

</select>

<input type="text" id="text" name="text" />

</form>

</body>

</html>

How do you define function in php?

A function is defined in php by placing the keyword function before the chosen function name.

The function name must not match a pre-defined function and has certain limitation as to the characters that can be part of it. Notably, the function name must not contain any spaces. Following the function name are a parenthesis-enclosed, comma-separated list of variables, these variables are called calling parameters and are helpful if the function must process some values or follows diferent branches depending on external variables. Finally the function body is enclosed in curly brackets { }.