Arrow

Recent Posts

Also in Category...


Q: What does PHP stand for?
A: PHP is an acronym that originally stood for Personal Home Pages.
Somewhere along the way the acronym was changed to mean PHP:
Hypertext Processor. The latter is considered a recursive acronym
because it references itself—the acronym (PHP) is inside the acronym.
Clever? Confusing? You decide!

Q: Even though my web browser shows that a web page has a name that ends in .php, it’s still pure HTML? How is that?
A: It’s possible because the page originates as PHP code on the
server but is transformed into HTML code before making its way to the
browser. So the server runs the PHP code and converts it into HTML code
before sending it along to the browser for viewing. This means that even
though a .php file contains PHP code, the browser never sees it—it only
sees the HTML code that results from running the PHP code on the server.

Q: But don’t all web pages originate on the server, even pure
HTML pages in .html files?
A: Yes. All of the files for a web site are stored on the server—.html,
.css, .php, etc. But they aren’t all processed by the server. HTML and
CSS files, as well as image files, are sent directly to the client browser
without worrying about what’s actually inside them. PHP files are different
because they contain code that’s processed and run on the web server.
It’s not the PHP code that’s sent to the browser, it’s the results of running
the PHP code that are sent, and these results are pure HTML and CSS.

Q: How do I know if my web server has PHP installed?
A: You could ask your web administrator or web hosting company, or you
could just perform a little test yourself. Create a text file called test.php
and enter the following code into it:
<?php
phpinfo();             This code asks PHP
?>                                                         to display information
                                                             about itself.
Q: Does it matter whether I put PHP commands in uppercase or lowercase?
A: Yes and no. For the most part, PHP isn’t case-sensitive, so you can get away with mixing the case of most commands. That means you can use echo, ECHO, or EchO when echoing content. However, as a matter of convention, it’s a very good idea to be consistent with case in your scripts. Most PHP coders prefer lowercase for the vast majority of PHP code.

Q: So even if it’s a bad coding convention, I can mix and match the case of PHP code?
A: No, not entirely. The huge exception to the case insensitivity of PHP is variable names, which apply to data storage locations that you create. So let’s take the $email variable used in the Report an Abduction
script as an example. This variable name is case-sensitive, so you can’t refer to it as $EMAIL or $eMail. All variable names in PHP are case-sensitive like this, so it’s important to name variables carefully and then reference them consistently in your code. More on variable names in just a moment.

Q: Is it really OK to put both PHP and HTML code in the same file?
A: Absolutely. In fact, in many cases it’s absolutely necessary to do so.

Q: Why would I want to do that?
A: Because the whole idea behind a web server is to serve up HTML web pages to browsers. PHP doesn’t change that fact. What PHP allows you to do is change the HTML content on the fly with things like today’s date, data pulled from a database, or even calculated values such as the order total in a shopping cart. So PHP allows you to manipulate the HTML that goes into web pages, as opposed to them just being created statically at design time. It’s very common to have HTML code for a page with PHP code sprinkled throughout to plug in
important data or otherwise alter the HTML programmatically.

Q: Does PHP code embedded in an HTML file have to be on its own line, or can I embed it in an HTML line, like as part of an HTML tag attribute?
A: Other than needing to place your PHP code within the <?php and ?> tags, there are no restrictions in how you embed it in HTML code. In fact, it’s often necessary to wedge a piece of PHP code into the middle of HTML code, like when you’re setting the attribute of an HTML tag. This is a perfectly legitimate usage of PHP.

Q: I’ve seen PHP code that’s enclosed by <? as the start tag instead of <?php. Is that right?
A: Not really. Technically speaking, it’s legal, but it isn’t recommended. A server setting must be enabled for the short open
tag (<?) to work. The usual <?php tag always works, so it’s better to use that and know that your code will just work.

Q: If a web server always returns pure HTML code to a client browser, why do URLs show the PHP script name, like webpage.php?
A: Remember that every web page is the result of a two-sided communication involving a request from the client browser and a response from the web server. The URL is the basis of the request, while the content returned from the server is the response. PHP scripts are requested just like normal HTML web pages through URLs entered into the browser or linked from other pages, or as form actions. That explains why the URL for a PHP “page” shows the name of the PHP script. The other half of the equation is the response from the server, which is the resulting code that’s generated by the PHP script. Since most PHP scripts generate HTML code, it makes sense that the code
is HTML and not PHP. So it’s no accident that a URL references a .php file on a server, which causes PHP code to be executed on the server, ultimately resulting in pure HTML content being returned to the browser.

Q: Can PHP variables store any other kinds of data?
A: Absolutely. You can use variables to store Boolean (true/false) data. And numeric data can be either integer or floating-point (decimal). There are also arrays, which store a collection of data, as well as objects, which associate a collection of data with code that is used to manipulate the data. Arrays are covered a little later in this chapter, while objects are tackled in Chapter 12. There is also a special data type called NULL, which represents no value. For example, a
variable that hasn’t been assigned a value is considered NULL.

Q: What actually happens when I concatenate multiple strings together using periods?
A: Concatenation involves sticking more than one string
together to form a completely new string. The end result of
concatenating strings is always a single string, no matter how
many strings you started with. So when you concatenate strings
as part of an echo command, PHP combines the strings
together into one first, and then echoes that string to the browser.

Q: When I concatenate a variable with a string, does the variable have to contain text?
A: No. Although concatenation always results in a string,
variables don’t have to contain strings in order for you to
concatenate them. So say a variable contains a number, PHP
converts the number to a string first and then concatenates it.

Q: What happens to PHP code on the browser?
A: Nothing. And that’s because PHP code is never seen by
a browser. PHP code runs on the server and gets turned into
HTML code that’s sent along to the browser. So the browser is
completely unaware of PHP’s existence—web pages arrive as
pure HTML and CSS.

Q: OK, so how exactly does the server turn PHP code into HTML and CSS code?
A: First off, remember that by default the code in a PHP script
is assumed to be HTML code. You identify PHP code within a
script by placing it between <?php and ?> tags. The server
sees those tags and knows to run the code inside them as PHP,
and all of the code outside of those tags is passed along to the
browser as HTML.

Q: Right. But that still doesn’t explain how the PHP code
gets turned into HTML/CSS code. What gives?
A: Ah, that’s where the echo command enters the picture.
You can think of the echo command as outputting information
beyond the confines of the <?php and ?> tags. So the echo
command is the key to PHP’s ability to dynamically generate
HTML/CSS code. By concatenating strings of text with PHP
variables, you can construct HTML code on-the-fly, and then use
echo to output it to the browser as part of the resulting web
page. A good example of this is in Owen’s report.php
script when the <br /> tag is tacked on to the end of a piece
of text to generate a line break in HTML.

Q: What exactly is an escape character?
A: An escape character is a character that's either difficult to type or
would otherwise cause confusion in PHP code. You may be familiar with
escape characters from HTML, where they're coded a little differently, like &#169; or &copy; for the copyright symbol. PHP has a very small set of escape characters that are helpful for escaping things that might be confused with the PHP language itself, such as single quotes (\'), double quotes (\"), and of course, newlines (\n).

Q: If double-quoted strings are so cool, why have we used mostly single-quoted strings up until now?
A: Well, keep in mind that single-quoted strings are not
processed by PHP in any way, which makes them ideal for strings
that are pure text with no embedded variables. So we’ll continue
to use single‑quoted strings throughout the book unless there is a
compelling reason to use a double-quoted string instead. The most
important thing about using single vs. double quotes around strings is
to try and be as consistent as possible.

Q: What happens if I need to use a single quote (apostrophe) within a single-quoted string, as in 'He's lost!'?
A: This is where escape characters come in handy. To use a
single quote inside of a single-quoted string, just escape it as \',
like this: 'He\'s lost!'. The same applies to a double quote
inside of a double-quoted string—use \". You don’t have to escape
quotes when they don’t conflict, such as a single quote inside of a
double-quoted string: "He's lost!".

Q: So single-quoted strings support \' but not \n. How do I
know what escape characters I can use within single quotes?
A: Single-quoted strings only allow the \' and \\ escape
characters—all other escape characters can only be used in double quoted strings.
HELLO FRIEND,

Today i tell you how to get money from online ?? its very simple to earn money becoming a Freelencer .
Freelence.com give you chance to earn money from online by doing work on your home .
its anything as your skills and talent ,capacity of your work because there are millions of project on freelence.com ... you choose as your skills and complete it make money from it .
for earning from freelence there are are various step to make money from freelence ..
step 1: make id  go www.freelence.com-> create profiles
step 2: update profiles for employer to choose you easily means decorate your profiles that attract your employer .
step 3:enter in contest to show your skills .
step 4:search project as your skills and bid it for attracting to employer ..




 I hope you enjoy it my article any query give comment i resolve it  thanks ...!!

Followers