php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37442 Bad variable type from simplexml
Submitted: 2006-05-14 23:11 UTC Modified: 2006-05-14 23:51 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: warden at warden dot cz Assigned: helly (profile)
Status: Not a bug Package: SimpleXML related
PHP Version: 5.* OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: warden at warden dot cz
New email:
PHP Version: OS:

 

 [2006-05-14 23:11 UTC] warden at warden dot cz
Description:
------------
I have file conf.xml:

<conf>
    <frequency></frequency>
</conf>

If I use $conf = simplxml_load_file(conf.xml) in object and than put the value of frequency into object variable ($this->frequency = $conf->frequency) everything is OK, but if I want to use this value in sleep($this->frequency) function, an error is displayed: 

Warning: sleep() expects parameter 1 to be long, object given in...

If I try to get variable type of frequency, "object" is returned...when I settype($this->frequency, "integer"), everything works good...

List of compiled modules:
apache2, bzip2, cgi, cli, crypt, exif, force-cgi-redirect, ftp, gd, iconv, imap, mhash, mysql, ncurses, nls, pcntl, pcre, posix, readline, reflection, session, simplexml, spell, spl, ssl, truetype, xml, xpm, xsl, zip, zlib

Expected result:
----------------
Clasic sleep(30); with no error

Actual result:
--------------
Warning: sleep() expects parameter 1 to be long, object given in...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-14 23:40 UTC] warden at warden dot cz
I forgot to write my frequency value in this example, so that file looks like:

<conf>
    <frequency>30</frequency>
</conf>
 [2006-05-14 23:51 UTC] helly@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Right now this is by design. In PHP 6.0 we might be able to case SimpleXMLElement objects to any type and therefor a function that requires an integer would get an integer.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 11:01:28 2024 UTC