P
P
posters2019-08-21 11:49:20
PHP
posters, 2019-08-21 11:49:20

How to save the result of simplexml_load_file operation correctly?

How to correctly save the result of the simplexml_load_file function to a php file?
Tried to directly put the value in file_put_contents but the result is an empty file.

$xml_object = simplexml_load_file($val);
file_put_contents($dir_indices . "/" . $file_name . ".php", $xml_object, LOCK_EX);

Simplexml_load_file works correctly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2019-08-21
@posters

$xml_object you have this (suddenly) exactly xml object (and not a string variable). Therefore, you cannot write it to a file. And it's not entirely clear why.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question