The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 21, 2019, 01:53:10 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Easy way to handle a long variable...  (Read 2454 times)
tommytx
Expert
****
Offline Offline

Posts: 123


View Profile WWW
« on: September 07, 2011, 11:36:53 AM »

somewhere in here.. this forum someone used this method on one of my posts..
What I need is a way to handle a long variable easily such as...

$buff = start
djfkdjksdkafjklfjaklfjkldfjasdfldf
faklfjdkjdksdfjkddfkjdfsdfkdfsdf
afkjfldjfklajdfjkdfjsdflaklasdfasdfsdf
kafkljkfdjsdfjsdfsdfjsdfdfklsdfkdfklasdfkldf
End

I am sure this is wrong but someone can remind me how to do it...
I want the variable to scoop up all the stuff from start to end... and place in the variable $buff

I know its simple but not if you dont' remember how..

Thanks.

Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: September 07, 2011, 12:09:26 PM »

It's called a HEREDOC and there just doesn't seem to be an easy way to find it if you don't know it's name.

$buff = <<<SOMETEXT
Four score and seven years ago
our fathers brought forth to 
$thisCountry
a new nation, conceived in 
{$obj->Liberty()}
and dedicated to the proposition that
{$men['all']} are created equal.
SOMETEXT;

Note that the closer MUST be on the left side, no white space in front of it allowed.

<edit>Text INSIDE the heredoc does not need to be on the left spine, all whitespace is honored.</edit>
« Last Edit: September 07, 2011, 12:11:55 PM by perkiset » Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
tommytx
Expert
****
Offline Offline

Posts: 123


View Profile WWW
« Reply #2 on: September 07, 2011, 12:17:57 PM »

Tanks... that's it...
Logged
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #3 on: September 07, 2011, 11:47:39 PM »

It's called a HEREDOC and there just doesn't seem to be an easy way to find it if you don't know it's name.

I agree, but this might be easier to recall nex time:

"php echo multiple lines"

Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!