Jump to content

PHP Struct


asprsai

Recommended Posts

hello guys.,

 

I need small help from. I am a java developer and am not well acquainted with php. I am developing a java application which calls a php web service (sugar CRM soap webservice)., so one of the web service method (login) takes a php struct as a parameter, user_auth which has three parameters username, password and version, all of them are strings. Can any one tell me what will be the output structured like when we print out the user_auth struct.

 

I tried:

1) String user1 = "user_auth{username=will; password=18218139eec55d83cf82679934e5cd75; version=1.0;}";

2) String user2 = "{'user_auth':{'username':'will','password':'18218139eec55d83cf82679934e5cd75', 'version':'1.0'}}";

 

Does any of the above strings match the output of a struct in php? If not what should it be like??

 

This would be of a great help for me if any one can tell me whats the right now.

 

Thanks,

aspr

Link to comment
Share on other sites

The second one comes close, just switch the single quotes and double quotes:

<?php
$user3 = '{"user_auth":{"username":"will","password":"18218139eec55d83cf82679934e5cd75","version":"1.0"}}';
?>

would be the json encoded form of an object or array. To see what it is in PHP, do either

<?php
print_r(json_decode($user3));
?>

which produces


stdClass Object
(
    [user_auth] => stdClass Object
        (
            [username] => will
            [password] => 18218139eec55d83cf82679934e5cd75
            [version] => 1.0
        )

)

or

<?php
print_r(json_decode($user3,true));
?>

which produces


Array
(
    [user_auth] => Array
        (
            [username] => will
            [password] => 18218139eec55d83cf82679934e5cd75
            [version] => 1.0
        )

)

 

Ken

Link to comment
Share on other sites

Thanks for replying..  Actually those strings (user1 and user 2) are java strings., so i want to send a java string to a php web service., so that the php should be able to covert the java string and take it as a complex type(struct).

 

So i will be passing the java string (user1 or 2 or 3) to the php web service and it should be able to recognize it as a struct.

 

I tried the one you mentioned (user3) its not working., i might be doing something wrong.

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.