php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64880 Perhaps more detail on how to get the value of 'foo' and 'bar' in 'myClass' ?
Submitted: 2013-05-20 11:02 UTC Modified: 2013-05-20 20:43 UTC
From: lifehome at usociety dot info Assigned:
Status: Not a bug Package: *General Issues
PHP Version: Irrelevant OS: Debian Squeeze
Private report: No CVE-ID: None
 [2013-05-20 11:02 UTC] lifehome at usociety dot info
Description:
------------
---
From manual page: http://www.php.net/function.get-class-vars#refsect1-function.get-class-vars-examples
---
I understand the first part, but how do I get the value of 'foo' and 'bar' in the functino of 'myClass" within the class 'myClass'? It's confusing me while the get_class_vars() and get_class()... I'm totally a noob on PHP programming so please point out if I was wrong...

Test script:
---------------
' http://pastebin.com/xGXgnBEd ' -- the class I use
===================================================
A string returns from the link: 1367502965000:deprecated:abcget:1968194347980167531:ce391600756e455db7a529f11fe6f558
===================================================
<?php

$username = abcget
$password = foobar

$api = new MinecraftAPI();

$apinfo = get_object_vars(get_class($api->login));
$api_array = $apinfo['minecraftValues'];
$ign = $api_array[2];
$uid = $api_array[4];

echo $ign."<br/>;
echo $uid;

Expected result:
----------------
abcget<br/>ce391600756e455db7a529f11fe6f558


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-05-20 20:22 UTC] mail+php at requinix dot net
That function and page are an explanation of the get_class_vars() function and 
as such merely talk about how to use it. What you need is something that 
explains objects in PHP as a general subject.

http://php.net/language.oop5

Your specific question of how to access $var1 and $var2 from within the class is 
addressed on the "Properties" page.

http://php.net/language.oop5.properties

Meanwhile your test script shows something else entirely and is better answered 
elsewhere: bugs.php.net is strictly for bug reports, not for individual help 
with problems. You should find yourself an online forum, mailing list, or an 
offline community for your questions.
 [2013-05-20 20:43 UTC] nikic@php.net
-Status: Open +Status: Not a bug
 [2013-05-20 20:43 UTC] nikic@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 12:01:33 2025 UTC