Ask a Question related to PHP Development, Design and Development.
-
JS Bangs #1
Object properties in echo()
I started using PHP's object-oriented stuff a little while ago, which has
mostly been a joy. However, I've noticed that they don't seem to echo as I
would like. Eg:
$this->field['id'] = 255;
$this->key = 'id';
echo "$this->key is $this->field[$this->key]"; // prints "id is Array[id]"
// Thus I am forced to do this
$keyval = $this->field[$this->key];
echo "this->key is $keyval"; // prints "id is 255"
echo "this->key is " . $this->field[$this->key]; // also works
This example is trivial, but it becomes much more of a nuisance when I'm
making forms and whatnot and don't want to have to define a whole bunch of
new variables or keep opening and closing quotes. Is there a workaround or
different syntax I can use for this, or am I just stuck?
Jesse S. Bangs [email]jaspax@u.washington.edu[/email]
[url]http://students.washington.edu/jaspax/[/url]
[url]http://students.washington.edu/jaspax/blog[/url]
Jesus asked them, "Who do you say that I am?"
And they answered, "You are the eschatological manifestation of the ground
of our being, the kerygma in which we find the ultimate meaning of our
interpersonal relationship."
And Jesus said, "What?"
JS Bangs Guest
-
object properties
I am using the trial version of Contribute CS3. When I edit a page and select a check-box or field, how can I inspect and change its properties? The... -
listing Object properties from SearchResult
Hi I have the following lines of code that are suppose to list some selected properties of all the object entries in a SearchResult but the code is... -
The Sound Object - causing an echo effect---help!
Hi everybody My problem is that i'm trying to get an audio sample playing at the start of the movie. In my first frame scene i create the sound... -
losing object properties when...
i lose the capability to change an object's width and height in the properties tab after using the extrude tool on it. the properties tab then just... -
Accessing all properties of an object at Runtime
Use reflection... "Softwaremaker" <msdn@removethis.softwaremaker.net> wrote in message news:<#b1mBjhQDHA.2432@TK2MSFTNGP10.phx.gbl>... -
André Nęss #2
Re: Object properties in echo()
JS Bangs:
Yeah, enclose them in {}, e.g.:> I started using PHP's object-oriented stuff a little while ago, which has
> mostly been a joy. However, I've noticed that they don't seem to echo as I
> would like. Eg:
>
> $this->field['id'] = 255;
> $this->key = 'id';
> echo "$this->key is $this->field[$this->key]"; // prints "id is Array[id]"
>
> // Thus I am forced to do this
> $keyval = $this->field[$this->key];
> echo "this->key is $keyval"; // prints "id is 255"
> echo "this->key is " . $this->field[$this->key]; // also works
>
> This example is trivial, but it becomes much more of a nuisance when I'm
> making forms and whatnot and don't want to have to define a whole bunch of
> new variables or keep opening and closing quotes. Is there a workaround or
> different syntax I can use for this, or am I just stuck?
"{$this->key} is {$this->field[$this->key]}";
See:
[url]http://www.php.net/manual/en/language.types.string.php#language.types.string.pa rsing[/url]
and in particular:
[url]http://www.php.net/manual/en/language.types.string.php#language.types.string.pa rsing.complex[/url]
André Nęss
André Nęss Guest



Reply With Quote

