Jump to content

csplrj

Members
  • Posts

    54
  • Joined

  • Last visited

Posts posted by csplrj

  1. json_decode returns a stdClass Object.

    Is there any way where I can get instance of my class instead of the same?

     

    I mean If I json_decode the below string then it will provide me instance of stdClass and not instance of Person class

    {"name":"a"}

     

    How to achieve the same?

     

    Thanks in advance

     

    CSJakharia

  2. Does anyone knows of any library or utility which can give me the same functionality as http://commons.apache.org/beanutils/apidocs/org/apache/commons/beanutils/package-summary.html#package_description gives in Java.

     

    A way by which I can access nested property of the Class

    I found one but it supports simple property only not nested property

    http://www.zend.com//code/codex.php?ozid=1481&single=1

     

    Thanks in advance

     

    CSJakharia

  3. Thanks for the link given as it helped me in identifying the issue

     

    I changed the json string and then When I try it does not works in PHP Version 5.2.4 but it works on PHP Version 5.3.1.

    I have my shared hosting on PHP Version 5.2.4. How to do the same

     

    <?
    $pages=$_POST['pages'];
    if($pages!=null)
    {
    	$pages1=json_decode($pages);
    	var_dump($pages1);
    }
    ?>
    <form method="post" id="addPage">
    <input type="hidden" value='[{"parentPageId":0, "id":0},{"parentPageId":0, "id":68},{"parentPageId":0, "id":69},{"parentPageId":69, "id":70},{"parentPageId":0, "id":71}]' id="pages" name="pages"/>
    <input type=submit>
    </form>

     

    Thanks in advance

     

    CSJakharia

  4. Below is the output for $pages

     

    [{"id":0},{"id":64, "websiteId":14, "pageName":"Home", "parentPageId":0, "pageTypeId":1, "orderNo":1, "pages":[]},{"id":65, "websiteId":14, "pageName":"a", "parentPageId":0, "pageTypeId":1, "orderNo":2, "pages":[{"id":66, "websiteId":14, "pageName":"b", "parentPageId":65, "pageTypeId":1, "orderNo":3, "pages":[]]},{"id":66, "websiteId":14, "pageName":"b", "parentPageId":65, "pageTypeId":1, "orderNo":3, "pages":[]},{"id":67, "websiteId":14, "pageName":"c", "parentPageId":0, "pageTypeId":1, "orderNo":4, "pages":[]}]
    

  5. Below is the code I have written for php json decoding.

    Can't understand the reason

     

    Thanks in advance

     

    CSJakharia

     

     

    PHP File

    <?
    $pages=$_POST['pages'];
    if($pages!=null)
    {
    	$pages1=json_decode($pages);
    	//echo((json_encode(array('a'=>1,'b'=>2))));
    	echo($pages);
    	var_dump($pages1);
    	echo PHP_EOL;
    	//echo($pages1);
    	echo(' JSONERROR='.json_last_error());
    }
    ?>
    <form method="post" id="addPage">
    <input type="hidden" value='[{"id":0},{"id":64, "websiteId":14, "pageName":"Home", "parentPageId":0, "pageTypeId":1, "orderNo":1, "pages":[]},{"id":65, "websiteId":14, "pageName":"a", "parentPageId":0, "pageTypeId":1, "orderNo":2, "pages":[{"id":66, "websiteId":14, "pageName":"b", "parentPageId":65, "pageTypeId":1, "orderNo":3, "pages":[]]},{"id":66, "websiteId":14, "pageName":"b", "parentPageId":65, "pageTypeId":1, "orderNo":3, "pages":[]},{"id":67, "websiteId":14, "pageName":"c", "parentPageId":0, "pageTypeId":1, "orderNo":4, "pages":[]}]' id="pages" name="pages"/>
    <input type="hidden" value='[{"id":0},{"id":64, "websiteId":14, "pageName":"Home", "parentPageId":0, "pageTypeId":1, "orderNo":1, "pages":[]}]' id="pages" name="pages1"/>
    <input type=submit>
    </form>

     

     

    But this output comes

    NULL JSONERROR=2

     

  6. I want to call

     

    $addRecord->Documents[0]->name = 'a'

     

    but as "Documents" and "name" come from runtime I tried

    $addRecord->$docs[$i++]->$name = 'a'

     

    But it calls instead

    $addRecord->D->name = 'a'

     

    I want to call $addRecord->Documents[0]->name = 'a'.

    But instead it calls $addRecord->D->name = 'a'?

     

    How to achieve the same

     

    Thanks in advance

     

    CSJakharia

  7. I have a long running script which may go on for long time may be 4 to 5 hours?

    How to get running the same in a shared hosting environment?

     

    As I tried the same but it seems it does not works in a shared hosting environment?

     

    I tried

    set_time_limit(0);

    ignore_user_abort();

     

    but it does not seems to works

     

    Thanks in advance

     

    CSJakharia

  8. I have a HTML document in which there is a <td> tag

    In this td tag the TextContent is equal to "Type"

    It is not neccessary that the td tag directly has content,it may have content in the subtags.

     

    The "Type" stuff may be enclosed in between the spaces

     

    What will be the XPath expression for the same. i am trying this using DomXpath of pHP?

     

    <td align="left" style="background-color:#648190;"><span style="color:#ffffff;font-family:arial;font-size:small;"><b>  Type</b></span></td>

     

    Thanks in advance

     

    CSJakharia

×
×
  • 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.