# Scary note for gettype() in docs

- Thread: https://externals.io/message/47074
- Original archive: https://news-web.php.net/php.internals/47074
- Started by Stan Vassilev on 2010-03-01T20:35:24+00:00
- Messages: 7
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #47074 — Stan Vassilev — 2010-03-01T20:35:24+00:00

URL: https://externals.io/message/47074#47074

Hi,

The `gettype()` documentation warns people that the returned string is "subject to change". Why is there a function that's subject to change in the API?

And just to clarify: I agree is_*() is better if we test for a certain type (as the note says). However, the use scenario for `gettype()` is when we do not test for a certain type (as in, we test for any type), which is less optimal when executed as 5-6 is_*() calls.

Regards, 
Stan Vassilev

---

## #47077 — Markus Fischer — 2010-03-01T22:23:58+00:00

URL: https://externals.io/message/47074#47077 · In reply to: #47074

> The `gettype()` documentation warns people that the returned string is "subject to change". Why is there a function that's subject to change in the API?

Probably because of the unicode stuff, might suddenly return "unicode"
(still true? don't know) or "binary" what was "string" before .. but
this is untested theory right now, but that's the kind of scenario they
mean here.

HTH

---

## #47079 — Antony Dovgal — 2010-03-01T22:27:17+00:00

URL: https://externals.io/message/47074#47079 · In reply to: #47074

> 
> Hi,
> 
> The `gettype()` documentation warns people that the returned string is "subject to change". 
> Why is there a function that's subject to change in the API?

Because life is complicated. 
Because gettype("test") returns "string" in 5.x and "unicode" in 6.0.

What exactly are you trying to fix? And what exactly are you proposing?

-- 
Wbr,
Antony Dovgal
---
http://pinba.org - realtime statistics for PHP

---

## #47080 — Victor Bolshov — 2010-03-02T05:33:32+00:00

URL: https://externals.io/message/47074#47080 · In reply to: #47079

From the user point of view it might seem that 5.x "string" and 6.x
"unicode" are all strings, whatever you call them. Still, I am sure
there _is_ a background for the decision to distinguish between
"string" and "unicode".

2 марта 2010 г. 1:27 пользователь Antony Dovgal <tony@daylessday.org> написал:
> 
> > […]
>
> Because life is complicated.
> Because gettype("test") returns "string" in 5.x and "unicode" in 6.0.
>
> What exactly are you trying to fix? And what exactly are you proposing?
>
> --
> Wbr,
> Antony Dovgal
> ---
> http://pinba.org - realtime statistics for PHP
>
> --
> 
> 
>
>



-- 
С уважением,
Виктор

---

## #47081 — Stan Vassilev — 2010-03-02T08:22:44+00:00

URL: https://externals.io/message/47074#47081 · In reply to: #47079

> 
> > […]
>
> Because life is complicated.
> Because gettype("test") returns "string" in 5.x and "unicode" in 6.0.
>
> What exactly are you trying to fix? And what exactly are you proposing?

If I have to propose anything, that'd be for 6.0 unicode strings to return 
"string" and binary strings to return "binary", as that is more apt for the 
real-world use cases people will find themselves in (and migrating code will 
be easier).

A PHP user stumbled onto the "subject to change" note and asked if it's safe 
to use. If differentiating both types of strings in 6.0 is what was 
intended, then it's perfectly safe to use, and I'll probably file an issue 
with docs to be more clear about the actual situation.

Regards,
Stan Vassilev

---

## #47082 — Derick Rethans — 2010-03-02T10:25:15+00:00

URL: https://externals.io/message/47074#47082 · In reply to: #47080

> From the user point of view it might seem that 5.x "string" and 6.x
> "unicode" are all strings, whatever you call them. Still, I am sure
> there _is_ a background for the decision to distinguish between
> "string" and "unicode".

Yes, there *has* to be a difference between "string" and "unicode" 
because otherwise you can't distinguish between binary goo and strings.

Derick

-- 
http://derickrethans.nl | http://xdebug.org
twitter: @derickr

---

## #47083 — Richard Quadling — 2010-03-02T10:54:55+00:00

URL: https://externals.io/message/47074#47083 · In reply to: #47082

> 
>
> > […]
>
> Yes, there *has* to be a difference between "string" and "unicode"
> because otherwise you can't distinguish between binary goo and strings.
>
> Derick
>
> --
> http://derickrethans.nl | http://xdebug.org
> twitter: @derickr
>
> --
> 
> 
>
>

So <PHP6, "this" is a string and in PHP6+ u"this" is a string and
"this" would be binary?

If PHP6 is unicode, then unicode strings are now the "normal" strings.
Binary strings are just binary data now. Maybe "string" and "binary
string" rather than "unicode" and "string".

So "string" is consistent across the PHP versions.


-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
