Code2Design.com

User login

The Layout

Programming

Graphic Design

Resources

Navigation

C2D Projects

Unsystematic Affiliates

Xtreme Pixel Flash Valley Proof That God Exists Tutorial Index 

Change Language

Who's online

There are currently 0 users and 11 guests online.

Lesson 3 - Strings

Watch the Movie of Lesson 3

Strings

Strings in PHP could be thought of as sentences such as: "I went to the store". Strings differ from variables in that they are a COLLECTION of values in one variable.
Example:

<?php
$variable 
'9';
$string 'abcdefghijklmnopqrstuvwxyz';
?>

Stings can be used to store names, tiles, addresses, and all kinds of things. So expect to use them often! Just like variables - you don't need to tell the computer that it is a "string". The computer can tell just by what value you put in it.

<?php
$0//var
$'Hi'//string
$"Fast Monkey"//string
$'K'//var 
?>

I highly recommend you read Codewalkers String Primer.

Here are some links to help you learn more about strings:
tizag.com - Strings
Zend.com - Adv. Strings
PHP - Strings Type


Submitted by David on November 9, 2006 - 5:53pm.
printer friendly version

so let me make sure this is correct....

The difference between a variable and a string is that a variable for the value will house only 1 character (rather number or letter) and a string, the value is more then 1 character (rather number or letter). Are my examples below correct?

// this is a variable
$variable = '4';

// this is a string
$variable = '456344534';

// another string
$teacher = "Ms. Doughtfire";

// another variable
$school_code = '9';

Is this correct?

----------------------------------------------------
Brand New to PHP Coding. Starting Learning 01/01/2007! This is my year to learn PHP.


Yes, it is correct

except for this one:

<?php
// this is a string
$variable '456344534';
?>

It would be a variable holding the number 456,344,534.
<?php
// this is a string
$variable "456344534";
// this is a variable
$variable 456344534;
// this is a variable
$variable '456344534';
// this is a string
$variable 'hi';
?>


Oh okay. I got that now. Im

Oh okay. I got that now. Im going to add this to my notes.

----------------------------------------------------
Brand New to PHP Coding. Starting Learning 01/01/2007! This is my year to learn PHP.


Thank You

Thank you for this lessons. I started today to learn PHP ... and this site is a real school


Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br> <br /> <h3>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use BBCode tags in the text, URLs will be automatically converted to links
More information about formatting options



Like what you see?

Why not add more? C2D is looking for other Christian Web Masters who would like to help write articles for this site. If you have expericance in FLASH, CSS/HTML, PHP/MySQL, PhotoShop/GIMP, Blender, Javascript, or just General Design - our users would love to hear what you have to say. Contact Us

delicious   digg   reddit   magnoliacom   newsvine   furl   google   yahoo   technorati