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 the maximum size of a file that can be uploaded using PHP and how can you change this?

By default, the maximum upload size in PHP is 2MB. This is kept in the php.ini file. To allow for the upload of larger files you have 3 options.

  1. Change the php.ini file. You're going to go into your php.ini file and look for the lines:

    memory_limit = 8M

    post_max_size = 8M

    upload_max_filesize = 2M

    You want to change the upload_max_filesize. Make sure that you don't exceed the post_max_size (if you do, then change them both.) Also, it's a good idea to make sure that memory_limit is always larger than post_max_size. (This applies to all these solutions.)

    After making changes to php.ini, your webserver will need to be restarted.

  2. Assuming you can't get into php.ini, you're using Apache, and you're running PHP as a module, you can use an .htaccess file. That file should contain the following lines:

    php_flag file_uploads On

    php_value memory_limit 8M

    php_value post_max_size 8M

    php_value upload_max_filesize 2M

    You put the .htaccess file in the root web folder, and it will apply to all the folders beneath it. If you do this and the server gives you a HTTP code 500 "Internal Server Error" then you aren't running Apache as a module and you can't do it this way. If it doesn't so anything, it's possible that you don't have the permissions to overwrite the Apache config via .htaccess.

  3. Finally, if all else fails, you can attempt to add a php.ini file to the webroot. PHP should find this ini file and abide by it. You don't need to copy every setting (anything not here is still in the original.) So your file should look something like this:

    [PHP]

    ; Whether to allow HTTP file

    uploads. file_uploads = On

    ; Maximum amount of memory a script may consume (8MB)

    memory_limit = 8M

    ; Maximum size of POST data that PHP will accept.

    post_max_size = 8M

    ; Maximum allowed size for uploaded files.

    upload_max_filesize = 2M

    If that technique fails, then it's time to admit defeat and call your hosting provider or IT guys and ask, politely, that they fix this for you.

What is the name of php compiler?

PHP isn't compiled it is interpreted, however you can cache it and make it much faster by using something like EAccelerator.

How do you get the length of an ANSI string using PHP?

$string ="Guess my length"; $length = strlen($string);

now the $length will have the length of the string.

Who created The Language of PHP?

PHP is the Web development language written by and for Web developers.

PHP stands for PHP: Hypertext Preprocessor. The product was

originally named Personal Home Page Tools, and many people still

think that's what the acronym stands for. But as it expanded in scope,

a new and more appropriate (albeit GNU-ishly recursive) name was

selected by community vote. PHP is currently in its fifth major

rewrite, called PHP5 or just plain PHP.

How do you change 'hElLo WoRlD' to 'HeLlO wOrLd' in PHP?

The process will work similar to a cryptoquip. First, you need to set up a conversion array. Then, run a strtr() and make the conversion into a new string. The code will look something like this:

$input = "hElLo WoRlD";

$convert = array('A' => 'a', 'B' => 'b' ... ... 'Z' => 'z', 'a' => 'A' ... ... 'y' => 'Y', 'z' => 'Z');

$output = strtr($input, $convert);

You can also look into generating the array by other means, such as looking through char codes. It is important to make sure that the array keys are the start letters and the array values are the end letters. It does not matter in what order you populate the array, as long as all letter pairs (upper-to-lower and the other way too) are present.

How do you create a cookie and where will it placed in php?

You can set a cookie using the setcookie() function. You can do this as many times as you wish during your script. Remember that the cookie will not be available to PHP until the next time the page is loaded (or the script is called by a new HTTP request). On the next page, you can access the cookie data from the $_COOKIE super-global array. The key will be the name of the cookie, and the value will be the value you assigned to it the last time you set it.

How do you animate in php?

There's no direct way to do animation in PHP, as it's a server side scripting language. That means that from the browser's point of view, there is no PHP code. It's just a static document that happens to be generated using PHP on the server side. If you want to do animation, you'll need to include client side scripting such as Javascript or Flash (or an animated GIF if something that simple meets your needs).

How do you display message in php?

There are various ways of doing it. Here are a few examples:

printf("Hello world!");

echo "Hello world!";

print "Hello world!";

If you are looking to offer a pop-up message (a separate window with a button that the user must click to acknowledge), you would have to do it with Javascript instead.

How do you add with mysql for example karma systems you click the up arrow it adds 1 to the profile I want something similar How would I do that in php and mysql?

mysql_query("UPDATE foo SET bar = bar + 1");

That would be updating the field "bar" in the table "foo", incrementing it's value by 1. Note that for mysql_query to work, you first need to be connected to a database and have a table selected. You can do that using the "mysql_connect" and "mysql_select_db" functions.

Why the use php language?

  • It's available on Linux, Windows, and probably the Mac to.
  • Works well with MySQL, which is also free and latest versions offer almost enterprise level facilities.
  • Although technically a scripting language, but offers almost complete support for Object Oriented programming from version > 5, but > 5.3 is recommended.
  • As a scripting language it is particularly suited for web applications. Typically used with Apache it has excellent support for sessions, cookies, get/post data etc.
  • It's free and widely available as part of budget hosting packages.
  • You can install it on test and development servers, to your heart's content. No charge or licencing considerations to worry about.

What is module in drupal?

A Module in Drupal is an optional plug-in that adds functionality to the core of the Drupal Content Management System (CMS). An example could be one of the many social plug-ins for this open source CMS, which allow you to have the social buttons on your web pages, such as the "like" button or "tweet" button.

There are many modules of varying complexity, some are dependent on other modules, and will require you to install those other modules alongside. The Drupal website has a section where you can search for all kinds of modules and it generally provides a good explanation as to the functionality and compatibility of each module.

It is generally recommended that you install models to the sites/all/modules folder of your Drupal installation, as this keeps your chosen "optional" modules separate from the core installation (which includes modules also) and makes it easier to update the CMS when the time comes.

Modules are installed separately and which one you choose depends on the functionality that you require.

Why do you select the php for doing project?

It depends on personal choice. The reason PHP is used so extensively is probably cause it is platform independent, open-source, syntax is simple, it supports language interoperability through xml & json and a lot of frameworks and cms are available that too free of cost.

Is tuxradar.com a good place to learn php?

Yes, though many other resources exist. The online PHP manual is an excellent example.

Which loop is used in php?

while, do...while, for, foreach are used

How do you call javaScript function inside table?

<table>

<th onclick="checkData()">ID</th>

<th onclick="checkData()">Name</th>

</table>

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

function checkData()

{

// Your Javascript code here

alert("It Works");

}

</script>

What companies use php programming language?

This is a very broad question, many web design companies will make sites in PHP. Facebook for instance is made in PHP, although the have modified it a bit for their massive traffic!

How can you find candidates who knows php?

PHP Programmers are easy to find.

However, like most programmers, you would see them on forums about PHP programming.

Example sites are:

http://sitepoint.com

http://forums.digitalpoint.com

Some programmers can be found browsing the following sites:

http://stackoverflow.com

http://quora.com

So if you want to find programmers you would probably need to advertise on these sites.

For other free options, aside from posting on forums, you would need to join google groups that have PHP programmers as members. A good example of that is the CakePHP group, http://groups.google.com/group/cake-php

How do you make foreign key in wamp server phpadmin?

Normally one goes though a user interface to make a foreign key in a WAMP server. If this doesn't help one might look to a forum directly related to phpadmin issues.

How you can connect two webpage in php?

You can use: require('filename.extension');

Or: include('filename.extension');

What does the function require-once do in php?

PHP maintains four direct functions for bringing in code from other files/sources.

require() and require_once() bring code in from another source and PHP will refuse to run if it cannot load those files.

include() and include_once() bring code in just the same, but your script will continue to run if those files could not be parsed. Thus you would use it if the code is optional and not necessary.

The _once() functions tell PHP to keep a list of required/included files so far and ignore the request if it's already been done somewhere else. Otherwise, it'll parse the file twice and could cause your script to fail because the functions, classes, etc defined during the second load would conflict with those loaded the first time.

What is a php consultant?

PHP Consultant is a Expert PHP Developer who Guide PHP Development Process

Who should not use psyllium?

People who are suspected of having an intestinal blockage or who suffer from narrowing of the esophagus or any other part of the intestinal tract should not use psyllium.

What is the difference between php and mysql?

A simple answer is that PHP is a language while MYSQL is a software.

PHP

PHP is a interpreted language used mostly for server-side scripting. It uses an interpreter given by PHP.net website used along with apache or anyother server.

It is similar to languages as asp , jsp , python scripts as they nearly perform similar function of serverside scripting.

MYSQL

MYSQL on the other hand is a database server / client (depending upon which one you get)

The MYSQL uses SQL (structured Query Language ) Pronounced as Sequel, To store and retrieve data.

Most developers in web specially php use mysql on server side, but it is not limited to php it can be used along with almost all the languages to store and retrive data.

What is header in php?

header() is a php function used to modify and set HTTP headers sent to the browser.