Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #5547 > unrolled thread
| Started by | j <mung_me@att.net> |
|---|---|
| First post | 2012-04-16 21:45 -0400 |
| Last post | 2012-04-17 09:26 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.php
$this->delimiter in php explode j <mung_me@att.net> - 2012-04-16 21:45 -0400
Re: $this->delimiter in php explode Jerry Stuckle <jstucklex@attglobal.net> - 2012-04-16 22:08 -0400
Re: $this->delimiter in php explode "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-04-17 09:26 +0200
| From | j <mung_me@att.net> |
|---|---|
| Date | 2012-04-16 21:45 -0400 |
| Subject | $this->delimiter in php explode |
| Message-ID | <jmihvb$cna$1@news.albasani.net> |
I've written a function in a class
public $delimiter = ';';
...
public function some_function(){
echo $this->delimiter; // yields: ;
$SOME_ARRAY= explode($this->delimiter,$some_string);
echo $this->delimiter // yields: 1
So, running explode changes the value of the class variable $delimiter.
It's obvious I'm stepping on something, but I'm not sure what other than
there is a delimiter in explode. What does $this mean inside the explode
function?
Jeff
[toc] | [next] | [standalone]
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Date | 2012-04-16 22:08 -0400 |
| Message-ID | <jmijbf$206$1@dont-email.me> |
| In reply to | #5547 |
On 4/16/2012 9:45 PM, j wrote:
> I've written a function in a class
>
> public $delimiter = ';';
>
> ...
>
> public function some_function(){
> echo $this->delimiter; // yields: ;
> $SOME_ARRAY= explode($this->delimiter,$some_string);
>
> echo $this->delimiter // yields: 1
>
> So, running explode changes the value of the class variable $delimiter.
> It's obvious I'm stepping on something, but I'm not sure what other than
> there is a delimiter in explode. What does $this mean inside the explode
> function?
>
> Jeff
>
>
The following code works fine here.
<?php
class MyClass {
private $delimiter = ';';
public function myfunc() {
$str = 'abd;def;ghi';
echo $this->delimiter . "\n";
$arr = explode($this->delimiter, $str);
echo $this->delimiter . "\n";
}
}
$mc = new MyClass();
$mc->myfunc();
?>
$this in the explode() function means the same thing it does anywhere
else - it is referencing the object the function is a member of. In
this case it says you want the $delimiter member of the object (instead
of some other $delimiter variable).
I suspect your problem is somewhere else.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[toc] | [prev] | [next] | [standalone]
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
|---|---|
| Date | 2012-04-17 09:26 +0200 |
| Message-ID | <9v4k9cFdhoU1@mid.uni-berlin.de> |
| In reply to | #5547 |
Am 17.04.2012 03:45, schrieb j:
> I've written a function in a class
>
> public $delimiter = ';';
>
> ...
>
> public function some_function(){
> echo $this->delimiter; // yields: ;
> $SOME_ARRAY= explode($this->delimiter,$some_string);
>
> echo $this->delimiter // yields: 1
>
> So, running explode changes the value of the class variable $delimiter. It's obvious
> I'm stepping on something, but I'm not sure what other than there is a delimiter in
> explode. What does $this mean inside the explode function?
>
> Jeff
The error must be outside the shown code, as is the case with setting of
$some_string. The parameters here are okay.
Maybe just do a string search on "delimiter"?
/Str.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web