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 name of the first programming language?

1950 - EDSAC - > This is the First Programming Language i know

next is..

1954 - FORTRAN

1958 - ALGOL - 58

1958 - LISP

1960 - COBOL

1964 - RPG

1964 - PL\1

1965 - BASIC

1967 - LOGO

1968 - APL

1970 - PASCAL

1970 - Smalltalk

1971 - FORTH

1972 - PROLOG

1972 - C

1979 - Ada

1981 - Modula -2

1982 - Dbase

1984 - Turbo PASCAL

1987 - HyperCard

1990s - Visual Basic

1990s - HTML, VRML and JAVA

I got this from my book when im in HighSchool ^__^

What are the Difference between primitive data types and wrapper classes?

A primitive type is, in a way, built-in, in the language. This often includes different kinds of numbers, strings, and in some languages, dates and boolean. The other data type, other than primitive, is a compound, or user-defined, data type. For example, some languages allow the programmer to define compound data types, called a "struct" in C, or a "record" in Pascal, where the programmer can define (for example) a data of type point, consisting of x, y, and z coordinates. In object-oriented languages, these user-defined types are often defined as classes.

A primitive type is, in a way, built-in, in the language. This often includes different kinds of numbers, strings, and in some languages, dates and boolean. The other data type, other than primitive, is a compound, or user-defined, data type. For example, some languages allow the programmer to define compound data types, called a "struct" in C, or a "record" in Pascal, where the programmer can define (for example) a data of type point, consisting of x, y, and z coordinates. In object-oriented languages, these user-defined types are often defined as classes.

A primitive type is, in a way, built-in, in the language. This often includes different kinds of numbers, strings, and in some languages, dates and boolean. The other data type, other than primitive, is a compound, or user-defined, data type. For example, some languages allow the programmer to define compound data types, called a "struct" in C, or a "record" in Pascal, where the programmer can define (for example) a data of type point, consisting of x, y, and z coordinates. In object-oriented languages, these user-defined types are often defined as classes.

A primitive type is, in a way, built-in, in the language. This often includes different kinds of numbers, strings, and in some languages, dates and boolean. The other data type, other than primitive, is a compound, or user-defined, data type. For example, some languages allow the programmer to define compound data types, called a "struct" in C, or a "record" in Pascal, where the programmer can define (for example) a data of type point, consisting of x, y, and z coordinates. In object-oriented languages, these user-defined types are often defined as classes.

What are the differences between Java OOP and PHP OOP?

JAVA is an Object Based Programming Language.

it doesn't provide multiple inheritance and operator overloading.

while Object Oriented Lanuages provides both.

How do you insert PHP code into JavaScript?

PHP is server-side code which means that the code is executed on the web server. The pages are dynamically created and sent to the user's browser. JavaScript is a client-side code which means that it runs on the user's computer after the page has been sent from the server. It is possible to combine PHP commands within JavaScript commands. You would mainly use this in setting up starting variables for your JavaScript. Example: Another option is that you may consider using Ajax which allows you to dynamically call server-side code from JavaScript.

Is PHP a general purpose programming language?

I defiantly wouldn't call it General Purpose but if you are fluent in PHP then there is pretty much nothing you can't do in PHP (provided you understand HTML, CSS and JavaScript). I've used PHP for items which I could have made via programs such as Access and Visual Studios but PHP is more first hand and easier for me. One good point to programs in PHP is because they are Server-side it should work for all Users.

What is the difference between PHP and Visual Basic?

There is no difference between Visual Basic and Microsoft Visual Basic. We only remove the word 'Microsoft' to save our time and to tell others that what is the name of the company of Visual Basic.

Is PHP compatible with Java?

I think both of them are very good and useful, but they are different of course, for example java is more secure and safe programming, but is also depended how web browsers support it, php is the programming which is relevant for all web servers.

Can you specify variable field width in scanf format string?

Answer

You can't specify a variable field with a fixed format string, but you can get around this by making the format string variable:

int width; char format[20]; /* or whatever size is appropriate */ int value; ... sprintf(format, "%%%dd", width); /* generates a string like "%5d" */ scanf(format, &value);

The only drawback to this method, other than requiring two statements, is that the compiler can't do a sanity check on the arguments to scanf like it can when the format is a string constant.

Answer

If you want to specify a variable width in a printf format string (as opposed to scanf), you can do the following:

printf("%*d", width, num);

That will use the value of "width" as the width for formatting the value of "num" as a decimal integer.

What is the difference between php and cake php?

PHP is a programming language which is used to create server side pages which are process by server and CakePHP is a framework which is written using php which helps developers to create web pages or we can say web application easily and quickly. CakePHP is a tool to create web application.

Why PHP developers prefers Laravel?

Laravel is one of the most preferred PHP frameworks as it has auto-loading to remove maintaining your software, a built-in authentication system you don't have to re-invent for every application, and a lot of other pre-built items that make developing your app easier and faster.

How much should an 18 year old php developer be earning part time in the uk based on a fixed hourly wage with one company not as a freelancer With 5 plus years experience in php and MySQL?

You should be earning at least the minimum wage for an 18 year old (which is currently at £4.98/hr) unless you are doing an apprenticeship, in which case they can pay you as little as £2.65/hr.

5+ years with PHP and MySQL experience is pretty impressive for an 18 year old; it would mean developing since you were at least 13!

So let's assume you do 16 hours a week. That's what is usually agreed upon as "part-time" in the UK.

Let's say you do about 39 weeks out of 52 in the year. This is a rough estimate based on being part-time.

That's 16 hours * 39 weeks which is 624 hours in a year you work.

On 18 year old minimum wage that's (624*4.98) = ~£3108/yr.

On <19 year old apprentice minimum wage that's (624*2.65) = ~1654/yr.

Of course you may earn more or less depending on how much you work.

Work it out like so:

x = your total earnings

m = minimum wage for you

h = # hours you work a week

w = # weeks you work in the year

x = (m*(h*w))

JSF Vs PHP?

JSF, not very well known

JSF, Probably a strict-typed language and therefore difficult for beginners

JSF, Did i mention not very well known?

PHP, Very well known

PHP, Forgiving (also error prone, lets be fair)

PHP, Lots of community support

How do you get difference between two or more arrays in PHP?

The inherit function `array_dif($arrayOne, $arrayTwo, $arrayThree, ...)` is likely what you're looking for. It compares two or more arrays, and returns an array of values that are unique among the arrays.

Why PHP is more secure?

All server scripting language speak about it self, why it is secured. Individual perceptions varies on secure ness of a one particular server scripting language.

A programmer's focus is the areas of activities/actions he has to undertake as per the security specification for a particular scripting language to make it secured. It may be PHP,ASP or JSP.

PHP allows you to send emails directly from a script?

PHP allows you to send emails via your server. This is most commonly done with the mail function, though more efficient alternatives exist like the pear Mail package. Keep in mind that if you have not configured PHP (and your server) to send emails, none of those functions will work.

How do you generate random numbers in PHP?

Use the function "rand()" or "mt_rand()". Both functions will generate a random number (as a return value, so be sure to make it point to a variable - see examples). However, "rand()" is slower and uses a default PHP randomizing system. mt_rand() is four times as fast, and uses the Mersenne Twister randomizing format - which is much more random. Both functions have two optional parameters - a minimum integer and a maximum integer, respectively. By filling in these parameters, you will get a random number between the values you give (so, giving one and five will give you a random number that is no less than one, and no greater than five). These, again, are optional - and if left blank, the tiniest integer possible is no less than 0, and the largest integer possible is generated by the PHP function "getrandmax()" / "mt_getrandmax()" automatically. Examples, of which all are acceptable: ---- /* Examples using no parameters */ $randomNumber = rand(); $randomNumber = mt_rand();

/* Examples using parameters */ $randomNumber = rand(1, 5); $randomNumber = mt_rand(6, 10); ---- If your PHP build is version 4.2 or under, you will need to seed the random number generator with a value to base off of. "srand()" and "mt_srand()" (to be used with rand() and mt_rand() functions, respectively) can be used in this case. They both only have one optional parameter, which is any seed value - any number. If omitted, a random seed will be generated. More acceptable examples: ---- // Example using no parameters

srand();

$randomNumber = rand(); // Example using the seed parameter

srand(12345);

$randomNumber = rand(); // Example using the "mt" random format functions (without parameters)

mt_Rand();

$randomNumber = mt_rand(); // Example using the "mt" random format (with parameters)

mt_rand(12345);

$randomNumber = mt_rand(); ----

How can I know what PHP version my site is running on?

Set up a PHP file and put the following in it.

<?php

phpinfo();

?>

Then run it on the server, it will have all the information you will need including what version you are running.

How do you link an image to a PHP file?

Wrap the image tag in an anchor link

<a href="mypage.php><img src="mypic.gif" width="10" height="10" /></a>

What is the difference between SESSION and POST in PHP?

POST:

Taken from the HTTP 1.0 RFC (#1945:8.3)

The POST method is used to request that the destination server accept

the entity enclosed in the request as a new subordinate of the

resource identified by the Request-URI in the Request-Line. POST is

designed to allow a uniform method to cover the following functions:

o Annotation of existing resources;

o Posting a message to a bulletin board, newsgroup, mailing list,

or similar group of articles;

o Providing a block of data, such as the result of submitting a

form [3], to a data-handling process;

o Extending a database through an append operation.

SESSION:

http://us2.php.net/manual/en/reserved.variables.php#reserved.variables.session

An associative array containing session variables available to the current script. See the Session functions documentation for more information on how this is used.

This is a 'superglobal', or automatic global, variable. This simply means that it is available in all scopes throughout a script. You don't need to do a global $_SESSION; to access it within functions or methods, as you do with $HTTP_SESSION_VARS.

$HTTP_SESSION_VARS contains the same information, but is not a superglobal. (Note that $HTTP_SESSION_VARS and $_SESSION are different variables and that PHP handles them as such)

If the register_globals directive is set, then these variables will also be made available in the global scope of the script; i.e., separate from the $_SESSION and $HTTP_SESSION_VARS arrays. For related information, see the security chapter titled Using Register Globals. These individual globals are not superglobals.

When i click the php query button its asking to open or save?

Clearly, this is a case of the server not knowing what to do, so it treats it like any other file.

To run PHP scripts, you will need to configure your server to handle PHP files through the php-cgi or phpexecutable. For Apache, this is accomplished by editing httpd.conf

Add the following to the httpd.conf file:

PHPIniDir ""

LoadModule php5_module ""

AddHandler application/x-httpd-php .php

What is rand function?

If you are referring to PHP's rand function then.

The rand function is a function that is used to generate a random number between and including two fixed values or two varibles.

An example of this is:

$rand1 = rand(1,9);

echo ($rand1);

?>

This will generate a number between 1 and 9 including 1 and 9

Another exampe of this is:

$value1 = 1;

$value2 = 9;

$rand1 = rand($value1,$value2);

echo ($rand1);

?>

This is also generate a number between 1 and 9 including 1 and 9.

I hope this has helped you.

What is a program flow chart?

A diagramwhich uses a set of standardsymbols to represent the sequence of operations of a computer program. Such a chart may show, for instance, the steps of a subroutine. Also spelled programflowchart. Also called program flow diagram.