M
M
Mesuti2018-07-09 18:44:26
PHP
Mesuti, 2018-07-09 18:44:26

Executing php inside xml file?

Hey!
How to execute php script inside xml file?
Writes an error to the checkbox "<"
5b4378e60a0a2054160172.jpeg
Template

<?xml version="1.0" encoding="UTF-8"?>
<option><?php echo $tmp[7] ?></option>

The following tricks work:
<?php header('Content-Type: application/xml; charset=utf-8'); ?>

<![CDATA[ <?php echo $tmp[7] ?> ]]> // Не выполняется php, просто выводится текстом

<?php echo "<?xml version="1.0" encoding="UTF-8"?>"> // Выдает ошибку страницы

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
roswell, 2018-07-09
@Mesuti

In .htaccess:

AddType application/x-httpd-php .php .xml
php_flag short_open_tag off # чтобы PHP не матерился на <?xml ... ?>

Or in nginx.conf, in the location section, which passes processing to PHP-FPM:
location ~* \.(php|xml)$ {

L
Lander, 2018-07-09
@usdglander

Let's guess: the file, of course, has the .xml extension. And wrapping all *.xml to the web server in .htaccess is not configured.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question