Jump to content

[SOLVED] Very easy simple question


Way Out West

Recommended Posts

Got one which I am sure is easy for everybody around these parts:

 

I have been looking at some code and playing around with it:

 

A line in the code goes along the lines of:

 

echo "<td>" . $row['whatever'] . "</td>\n"

 

Now I get everything except, what is the  . bits between the table elements and also what does that \n mean?

 

Like I say I am sure it is simple, but Googling comes up with very little when you don't know what you are searching for!

 

Cheers.

Link to comment
https://forums.phpfreaks.com/topic/36766-solved-very-easy-simple-question/
Share on other sites

The . is the concatenator (spelling?). It connects two things together in a string. Example:

 

<?php
$a = "hello ";
$b = "world";
$c = $a . $b; //Contains "hello world"
?>

 

The \n is the newline character. It just says to move down a line. It's useful for keeping your source clean, and not only on one line.

The dot '.' is just a concatenation device in PHP (joins strings together). It's the same as joining strings with '+' in javascript. As for the '\n', that is a newline character. When used within double quotes, it causes the generated text to have a line break at the location of that character.

 

*doh* Beat to it again ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.