用php创建了很多svg

I try to load a simple text file where each line has a name and create svg's out of those names. It doesn't matter for now if those svg's are empty, i'm more interested in getting the file.

I use MAMP at the moment on a mac. If i run this script, then i don't see any files appearing. Am i doing something wrong or am I looking in the wrong direction? If I load the file I do see a error but it appear's to quick for me to read.

Please help.

<?php

error_reporting(-1);

$codes = file('someFile.txt');


foreach ($codes as $code) {

    ob_start();


echo '<?xml version="1.0" encoding="utf-8"?>';

?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="2075px" height="775px" viewBox="0 0 2075 775" enable-background="new 0 0 2075 775" xml:space="preserve">

<?php

    }

?>
</svg>
<?php 

    file_put_contents("out/$code.svg", ob_get_clean());

}

?>

You have a few issues:

$codes should be an array, since you are trying to use it in a foreach loop. The next issue is minor, and that is you have one too many closing brackets }. This can be resolved by eliminating the intermediate <?php code you have:

<?php

error_reporting(-1);

$codes = array('someFile','someFile2');

foreach ($codes as $code) {
    ob_start();

echo '<?xml version="1.0" encoding="utf-8"?>';
?>

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="2075px" height="775px" viewBox="0 0 2075 775" enable-background="new 0 0 2075 775" xml:space="preserve">
</svg>

<?php
    file_put_contents("/out/".$code.".svg", ob_get_clean());
}   
?>