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

What is Pearl-php?

Pearl is not a programming language and it's definitely not related to PHP. It's a pricey object you give to your significant other.

Perl on the other hand, is a scripted JIT programming language principally aimed at IO (file operations) whereas PHP is also a scripted JIT programming language but that is principally aimed at website server-side scripting.

What are the differences between require once and include once in PHP?

They're completely identical except how they output errors. Include produces a warning, while Require produces a fatal error.

What is the functionality of the function strstr and stristr in PHP?

With strstr you can find a certain letter, number, or symbol in a string. A basic function could be to figure out if an email address is valid or not.

$email = "email@email.com";

$domain = strstr($email,"@");

$dot = strstr($domain,".");

if ($domain "")

{

do something

}

else

{

do something else

}

?>

The strstr in $domain is looking for "@" in $email and the strstr in $dot is looking for a "." in $domain. The if means if $domain and $dot equal nothing(it would show up as blank because there is no "@" in $email so the strstr in $domain returns false and that would in turn return the strstr in $dot as false also), do something. then the else is if $domain and $dot equal something besides "" do something else.

The stristr function is just a Case-Insensitive version of strstr.

How many concatenation operators use in PHP?

There is one concatenation in PHP it is the period ".". So you could do something like:

echo "hello" . " " . "world!";

?>

It would print out hello world!

What is a lot code?

Lines of efficient code:

Tiny: 0-10 Small: 10-250

Medium: 250-500

Large: 500-1000

X-Large: 1000-5000 *

XX-Large: 5000-10000

Size of file:

Tiny: 0-2K

Small: 2-5K

Medium: 5-10K

Large: 20-50K *

X-Large: 50-100k

XX-Large: 100-500K

Always when the editors scroll bar is tiny you know that you have a pretty large file..

I am working on a full web.2 CMS and where i have included Astrix is what my main script it.. It is mostly in the one index.php but i also have plugins and the config.php and functions.php... my index.php file includes all from calling plugins to giving the JavaScript and css.

Why is PHP better than JSP?

in the past ive found jsp to be much slower than PHP (correct me if im wrong) PHP is a solid stable web language and much faster in my opinion :D

PHP program for electrical bill calculation?

<?php

function calculate_electric_bill( $cost_per_kilowatt, $killowatts_used )

{

return $cost_per_kilowatt * $kilowatts_used;

}

echo calculate_electric_bill( 0.01, 1000 );

How do you sort variable in ascending or descending order both in php?

Assuming that the values are stored in an array, you can use the php function sort($array) to sort ascending, and rsort to sort descending. The following link gives a table that lists all of the built in PHP sort functions:

http://php.net/manual/en/array.sorting.php

How can you run a php program?

To run PHP, just like any other programming/scripting language, you need to install an interpreter.
If you're planning on using the PHP on a website, you can have a PHP interpreter run alongside your Apache/Nginx installation. Go ahead and look up the relevant installation information for your server's OS.

What is the getopt function in PHP?

It gets options from the command line argument list. It can be used in PHP 4.3 and above, including PHP 5.

List out the predefined classes in PHP?

Classes are not like predefined functions-there are quite a lot of functions, a class is similar to creating your own function - on a very basic level please do not swamp me with lists of the differences between a class and a function I already know! -

anyway, anything predefined within php will be available to view in the PHP manual - downloadable from the php website and is part of the php package.

but to save you a bit of time here are a list of pre-defined classes (or rather resevered words that are classes):

http://php.net/manual/en/reserved.classes.php

Is Microsoft Access compatible with PHP?

Yes. PHP supports an API called ODBC that allows it to interact with Microsoft Access databases.

How do you test PHP without downloading anything?

Your can't, you need to download something like XAMPP to run the PHP scripts on your computer.

How do you install a PHP editor?

1. Choose a program that you prefer. Wordpad, Editplus, Dreamweaver

2. IF you need to purchase it. go to the website/shop and buy it.

3. install it on your machine

I used EditPlus for a few years as it colourises your code and it's free to trial and cheap to buy. I am using Dreamweaver at the moment and there's not that much difference apart from the FTP feature.

How do you install PHP scripts?

You need to upload the scripts to web hosting space that support PHP.

How can you create a language converter for website in English to Spanish in PHP?

You can use PHP to create a language converter for a website by storing language translations in a database or files, and then using PHP to dynamically switch the content based on the selected language. You can create language files for each language, and then use PHP sessions or cookies to store the user's language preference across pages. Finally, use PHP functions to display the content in the appropriate language based on the user's selection.

What are the different types of errors in PHP?

basicly four type errors in php

warnings

fatal

notices

parse

and internly

e_fatal

e_warning

e_fatal

e_user_error

e_user_warning

e_user_fatal

e_core_error

e_core_warning

e_compile_error

e_recvoverable_error

e_strict

e_all

How do you swap two numbers using PHP?

This is the answer:

<html>

<body>

<?php

$number1=20;

$number2=30;

$temp=$number2;

$number1 = $temp;

$number2 = $temp-10;

echo $number1;

echo $number2;

?>

</body>

</html>

How do you swap variables in PHP?

By using a third temporary variable.

$tmp = $a;

$a = $b;

$b = $tmp;

How long does it takes to learn PHP?

It varies depending on your previous experience with programming/scripting, HTML, and such, but generally PHP is considered quite an easy language to learn.

But as any language, it may be easy to learn to use it, but hard to learn to use it the right way.

What is the abbreviation of PHP?

It used to stand for Personal Home Page but today,the first P is dropped and stands for Hypertext Processor

When you need to obtain the ASCII value of a character which function apply in PHP?

ord() is the function you need.

echo ord(' ');

Would output the number 32.