php - Why using createElement value doesn't show my input element properly? -


i've following code:

$newdom = new domdocument('1.0', 'utf-8'); $foo = $newdom->createelement('input', 'this value'); $newdom->appendchild($foo); echo $newdom->savehtml(); 

this outputted only: <input>

but when change createelement 'div' works okay

this outputted 'div' or other input:

 <div>this value</div> 

this var_dump($foo):

object(domelement)#5 (17) {   ["tagname"]=>   string(5) "input"   ["schematypeinfo"]=>   null   ["nodename"]=>   string(5) "input"   ["nodevalue"]=>   string(16) "this value"   ["nodetype"]=>   int(1)    ["parentnode"]=>   string(22) "(object value omitted)"   ["childnodes"]=>   string(22) "(object value omitted)"   ["firstchild"]=>   string(22) "(object value omitted)"   ["lastchild"]=>   string(22) "(object value omitted)"   ["previoussibling"]=>   null   ["attributes"]=>   string(22) "(object value omitted)"   ["ownerdocument"]=>   string(22) "(object value omitted)"   ["namespaceuri"]=>   null   ["prefix"]=>   string(0) ""   ["localname"]=>   string(5) "input"   ["baseuri"]=>   null   ["textcontent"]=>   string(16) "this value" } 

the second argument createelement content of tag you're creating. <input> tags can't contain text. need set value attribute. you're trying produce <input value="this value">, not <input>this value</input>.

see createattribute.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -