Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #8521 > unrolled thread
| Started by | David Heller <daveh@allheller.net> |
|---|---|
| First post | 2013-03-03 14:10 -0800 |
| Last post | 2013-03-04 02:31 -0800 |
| Articles | 5 — 4 participants |
Back to article view | Back to comp.lang.php
Novice Question David Heller <daveh@allheller.net> - 2013-03-03 14:10 -0800
Re: Novice Question Gregor Kofler <usenet@gregorkofler.com> - 2013-03-04 00:38 +0100
Re: Novice Question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-03-04 01:52 +0100
Re: Novice Question Gregor Kofler <usenet@gregorkofler.com> - 2013-03-04 23:12 +0100
Re: Novice Question Captain Paralytic <paul_lautman@yahoo.com> - 2013-03-04 02:31 -0800
| From | David Heller <daveh@allheller.net> |
|---|---|
| Date | 2013-03-03 14:10 -0800 |
| Subject | Novice Question |
| Message-ID | <c7f12a71-9e2b-4296-a0c6-27e014fb1d22@9g2000yqy.googlegroups.com> |
Hello I'm doing some maintenance/upgrade of some old php4.3 code and I ran across the following code snippet: $gvns = (array)$gvns; What it exactly is happening here? what does (array) mean? never seen anything like this before. Dave
[toc] | [next] | [standalone]
| From | Gregor Kofler <usenet@gregorkofler.com> |
|---|---|
| Date | 2013-03-04 00:38 +0100 |
| Message-ID | <kh0mrc$9g2$1@dont-email.me> |
| In reply to | #8521 |
Am 03.03.2013 23:10, David Heller meinte: > > Hello > > I'm doing some maintenance/upgrade of some old php4.3 code and I ran > across the following code snippet: > $gvns = (array)$gvns; > What it exactly is happening here? what does (array) mean? > never seen anything like this before. Type casting. (It's the same as $gvns = array($gvns); ) <http://www.php.net/manual/en/language.types.array.php#language.types.array.casting> Gregor
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-03-04 01:52 +0100 |
| Message-ID | <7592184.1qVRdKLYnM@PointedEars.de> |
| In reply to | #8522 |
Gregor Kofler wrote:
> Am 03.03.2013 23:10, David Heller meinte:
>> I'm doing some maintenance/upgrade of some old php4.3 code and I ran
>> across the following code snippet:
>> $gvns = (array)$gvns;
>> What it exactly is happening here? what does (array) mean?
>> never seen anything like this before.
>
> Type casting.
ACK.
> (It's the same as $gvns = array($gvns); )
Evidently it is not.
$ php -r 'class C {}; print_r((array) new C()); print_r(array(new C()));'
Array
(
)
Array
(
[0] => C Object
(
)
)
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
[toc] | [prev] | [next] | [standalone]
| From | Gregor Kofler <usenet@gregorkofler.com> |
|---|---|
| Date | 2013-03-04 23:12 +0100 |
| Message-ID | <kh365q$lok$1@dont-email.me> |
| In reply to | #8523 |
Am 04.03.2013 01:52, Thomas 'PointedEars' Lahn meinte: > Gregor Kofler wrote: > >> Am 03.03.2013 23:10, David Heller meinte: >>> I'm doing some maintenance/upgrade of some old php4.3 code and I ran >>> across the following code snippet: >>> $gvns = (array)$gvns; >>> What it exactly is happening here? what does (array) mean? >>> never seen anything like this before. >> >> Type casting. > > ACK. > >> (It's the same as $gvns = array($gvns); ) > > Evidently it is not. Indeed. My claim is only valid for scalar values. Gregor
[toc] | [prev] | [next] | [standalone]
| From | Captain Paralytic <paul_lautman@yahoo.com> |
|---|---|
| Date | 2013-03-04 02:31 -0800 |
| Message-ID | <d89dd34c-24f3-48c2-b5e8-5e90eed8fd6e@gp5g2000vbb.googlegroups.com> |
| In reply to | #8521 |
On Mar 3, 10:10 pm, David Heller <da...@allheller.net> wrote: > Hello > > I'm doing some maintenance/upgrade of some old php4.3 code and I ran > across the following code snippet: > $gvns = (array)$gvns; > What it exactly is happening here? what does (array) mean? > never seen anything like this before. > > Dave It is a construct often used to change object properties into an associative array. Another method (which may have slightly different results) is to use the get_object_vars() function. Search Google for php get_object_vars vs array cast to see discussions on the differences.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web