Academic Tutorials



English | French | Portugese | German | Italian
Google

Home Source Codes E-Books Downloads Contact Us About Us

PHP Tutorial
PHP Introduction
PHP Install
PHP Syntx
PHP Variables
PHP Operators
PHP Loops & Arrays
PHP Functions
PHP Forms
PHP Includes & Require
PHP File Handling
PHP Cookies
PHP Session
PHP E-mail
PHP SQL Database
PHP Summary

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
AJAX Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PHP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
.NET (dotnet)
Microsoft.Net
XML Web Services
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills


Variables in PHP

Previous Next



As with any other programming languages, PHP allows to define variables. In PHP there are many variable types,but the most common among them is a String variable.


String Variable

A String variable holds text and numbers. All strings begin with a symbol "$". To assign some text to the string you can use the following code:

$welcome_text = "Hello and welcome to VYOM Technosoft";

Strings are case sensetive so the string variable $Welcome_Text is not the same as $welcome_text A string name can contain letters, underscores and numbers. but it should not begin with a number or underscore. When assigning numbers to the string variables you need not include the quotes so:

$user_id = 987

would be allowed.



How to display the Variable.

We use exactly the same code to display a variable on the screen, as we used to display the text. But slightly different form. The following code would display the welcome text:

<?
$welcome_text = "Hello and welcome to VYOM Technosoft";
print($welcome_text);
?>


As you can see, the only major difference is that you need not put the quotation marks if you are printing a variable.


How to format the Text?

Output from your PHP programs is quite boring unfortunately. All the content is just output in the browser's default font. It is easy, to format your text using HTML. This is because, as we know that the PHP is a server side scripting language, code is been executed before the page is sent to browser. This means, only the resulting information from script is sent, so in the above example, the browser would just sent the text:

Hello and welcome to VYOM Technosoft


This means, that you can include standard HTML markup in your strings and scripts. The problem with this is that many HTML tags require the " symbol. You may notice that this symbol will clash with the quotation marks used to print the text. To overcome this confusion you must tell the script which quotes to be used (those at the beginning and end of the output) and which to be ignored (those of the HTML code).


How to solve this problem?

To illustrate this let us consider the example, Change the font of the text to the Arial font in red. The code for this is as follows.

<font face="Arial" color="#FF0000">
</font>


As you can see this code contains 4 quotation marks so can confuse the script. To solve this you must add a backslash before each quotation mark to make the PHP script ignore it. Then the code would look like.

<font face=\"Arial\" color=\"#FF0000\">
</font>


Now you can include this in your print statement,which will make the browser display it.

print("<font face=\"Arial\" color\"#FF0000\">Hello and welcome to VYOM Technosoft</font>");

Output:Hello and welcome to VYOM Technosoft





Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • connotea
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Netvouz
  • RawSugar
  • Reddit
  • scuttle
  • Shadows
  • Simpy
  • Smarking
  • Spurl
  • TailRank
  • Wists
  • YahooMyWeb

Previous Next

Keywords: php tutorial, php scripts, php nuke, php download, php editor, php mysql, php forum, php add link, learn php, php code


HTML Quizes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
XML Quizes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizes
JavaScript Quiz
VBScript Quiz
AJAX Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizes
ASP Quiz
PHP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
.NET (dotnet) Quizes
Microsoft.Net Quiz
XML Web Services Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
Multimedia Quizes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Web Building  Quizes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Java Quizes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Programming Langauges Quizes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Soft Skills Quizes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz

Privacy Policy
Copyright © 2003-2008 Vyom Technosoft Pvt. Ltd., All Rights Reserved.