PHP - function name must be a string

Error:

PHP Notice:  Undefined variable: exec in readings.php on line 3
PHP Fatal error:  Function name must be a string in readings.php on line 3

The code:

<?php
    require('smarty_config.php');
    exec('reading_fetcher.py',$output,$ret_code);
    $smarty->assign('readings',$output);
    $smarty->display('readings.tpl');
?>

The code asked me reading_fetcher.py, here it is:

#!/usr/bin/env python
import urllib2, re

response = urllib2.urlopen('http://it.ctsfw.edu/inc/nc_scriptureframe.php')

html = response.read()

def remove_html_tags(data):
    p = re.compile(r'<.*?>')
    return p.sub(' ', data)

import re
import htmlentitydefs

def convertentity(m):
    if m.group(1)=='#':
        try:
            return unichr(int(m.group(2)))
        except ValueError:
            return '&#%s;' % m.group(2)
        try:
            return htmlentitydefs.entitydefs[m.group(2)]
        except KeyError:
            return '&%s;' % m.group(2)

def converthtml(s):
    return re.sub(r'&(#?)(.+?);',convertentity,s)

readings =  converthtml(str(remove_html_tags(html)))
readings.replace("&nbsp;", " ")

print readings[699:]

I already looked here , here and here . Two of these errors are optional "$". I do not see the extra "$" in the name of my function. The third error has "()" instead of "[]". So I tried to replace them. This did not work. What else can I try?

+3
source share
1 answer

exec() . exec E_NOTICE E_WARNING. , , E_NOTICE , "exec ".

error_reporting(E_ALL);

.

+1

Source: https://habr.com/ru/post/1789158/


All Articles