Re: Cannot use string offset as an array



Tree*Rat escribió:
if( $this->$switch_b[$i]['module_id'] == $id )

You are using variable variables inadvertently:

http://es2.php.net/language.variables.variable

An example:

<?php

class Foo{
private $bar = 'I am bar';

public function printBar(){
$name = 'bar';

echo $this->bar . "\n"; // Prints 'I am bar'
echo $this->$name . "\n"; // Also prints 'I am bar'
}
}

$f = new Foo;
echo $f->printBar();

?>



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
.



Relevant Pages

  • Re: Checking PHP version for compatibility?
    ... private $foobar; ... public function __construct{ ... echo 'Foo'; ...
    (comp.lang.php)
  • Re: class fields vs class properties
    ... This field is a private field, and good OO practice dictates that fields should always be private, so they can't be accessed from outside the class Foo. ... So you'd have public methods that would allow for getting/setting the value of the bar variable, ... public int GetBar() { ...
    (microsoft.public.dotnet.general)
  • Re: howto decouple in .NET?
    ... If Foo embeds a private member Bar, then every user of class Foo ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Getting the names of variables passed to functions
    ... public function getValue() ... public var $bar; ...
    (comp.lang.php)
  • accessing a private member (illegally)
    ... Let's say I've got a class defined in a header file. ... int bar; ... Now lets say I have a function that needs to access the private variable ... I don't want to change anything inside the class foo ...
    (comp.lang.cpp)