splitting a variable
Moderator: General Moderators
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
off topic and probebly a stupid question but every time i create then write to a text file the first line is a blank line then the text starts on the second line. iv used the "r" mode to open it and the "r+" mode to write to it and it still goes to the second line no matter what. why is this and how do i get around it happening?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
-
Robert Plank
- Forum Contributor
- Posts: 110
- Joined: Sun Dec 26, 2004 9:04 pm
- Contact:
I love being able to use references for cool stuff but it looks like PHP is phasing them out.
I'm not saying don't learn them but if you have a script you plan on going out to a lot of people, that uses references, it might break. I had to rewrite a lot of code because of this not too long ago.
New versions of PHP have a setting on whether or not to complain about about references, I'm not sure if it's turned on by default or not, but basically it says not to use them in the future. Just so you know...
New versions of PHP have a setting on whether or not to complain about about references, I'm not sure if it's turned on by default or not, but basically it says not to use them in the future. Just so you know...
references are definately not being phased out.Robert Plank wrote:I love being able to use references for cool stuff but it looks like PHP is phasing them out.I'm not saying don't learn them but if you have a script you plan on going out to a lot of people, that uses references, it might break. I had to rewrite a lot of code because of this not too long ago.
New versions of PHP have a setting on whether or not to complain about about references, I'm not sure if it's turned on by default or not, but basically it says not to use them in the future. Just so you know...
in php5 objects are automatically passed by reference.
maybe your talking about :
allow_call_time_pass_reference
if set to on, this lets you specify whether a variable should be passed by reference when calling the function itself.
Code: Select all
// good, not being phased out way that will always work
function add_foo(&$text) { // notice reference is func definition
$text .= 'foo';
}
$bar = 'bar';
add_foo($bar); // $bar is now == 'barfoo'
//
//
//
// bad way, in php5, only works if: allow_call_time_pass_reference = On
function add_foo($text) { // notice NO reference is func definition
$text .= 'foo';
}
$bar = 'bar';
add_foo(&$bar); // notice reference at call_time, badso its not that references are bad, its just the way you use them. what feyd did is not affected by this at all, and totally allowed.
-
Robert Plank
- Forum Contributor
- Posts: 110
- Joined: Sun Dec 26, 2004 9:04 pm
- Contact: