FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » print_r
Show: Today's Messages :: Unread Messages :: Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
print_r [message #175872] Thu, 03 November 2011 11:24 Go to next message
bob is currently offline  bob
Messages: 11
Registered: February 2011
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
Can I count on the print_r function to output info in the same format
always?

I did a print_r on an array and got something like this:

Array
(
[status] => 0
[email] => bob(at)coolgroups(dot)com
[firstname] => bob
[lastname] => smith
[id] => 148
[access] => 2040ad981d3302d63564b990fea38268
)


I want to make sure that doesn't change in PHP 6 or 7.
Message by Jerry Stuckle is ignored  [reveal message]  [reveal all messages by Jerry Stuckle]  [stop ignoring this user] Go to previous messageGo to next message
Re: print_r [message #175874 is a reply to message #175872] Thu, 03 November 2011 12:53 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
remove from buddy list
ignore all messages by this user
On Thu, 03 Nov 2011 08:24:01 -0700, bob wrote:

> Can I count on the print_r function to output info in the same format
> always?

No, if you want a consistently formatted text representation of an array
to, for example, transfer data between applications, you might be better
either using the json encoding, or the built in serialisation, or writing
your own array to text function.

Obviously, whichever one you use, you'll need matching routines at the
the other end. json encoding is fairly well supported with code or
libraries available for many different languages at www.json.org

Although there's nothing there for ada, fortran or pascal yet :(

Rgds

Denis McMahon
Re: print_r [message #175915 is a reply to message #175872] Mon, 07 November 2011 03:28 Go to previous message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
El 03/11/2011 16:24, bob escribió/wrote:
> Can I count on the print_r function to output info in the same format
> always?
>
> I did a print_r on an array and got something like this:
>
> Array
> (
> [status] => 0
> [email] => bob(at)coolgroups(dot)com
> [firstname] => bob
> [lastname] => smith
> [id] => 148
> [access] => 2040ad981d3302d63564b990fea38268
> )
>
>
> I want to make sure that doesn't change in PHP 6 or 7.

I wouldn't count on that. You probably have a better chance with
var_dump() which (apart from being more accurate) is used in unit
testing in the PHP code itself. E.g.:

http://svn.php.net/viewvc/php/php-src/trunk/tests/func/010.phpt?view=markup

I mean, they can change it whenever they want, but they'll break their
own tests.

(I hope you're are planning to write unit tests or something like that;
there are betters choices to store or transmit information.)



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: shiping cart program
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Oct 09 05:27:07 EDT 2024

Total time taken to generate the page: 0.06780 seconds