My database tables 1 row looks like that

I'm storing all variables that used in body, in another column named vars. Then fetching all vars. If they are multiple, exploding by "," symbol. 
What I want to do is, fetch all used vars from db, then filter them by second function filter. As you see, filter has, 3 inputs: $content, $needle, $replacement . 
$content - messages body,
$needle - %.what we are searching for.%
$replacement - is var that we got from database, defined by php. For ex, if I get wsurl from database, It's already defined in my settings.php like DEFINE("wsurl", "www.yourdomain.com").
Question is, how can I send defined value as third input - $replacement?
public function genMsg($id) {
    $msgid = $id;
    $stmt = $db->prepare('SELECT `body`, `status`, `vars` FROM `messages` WHERE `id`=?') or die(htmlspecialchars($this->db->error));
    $stmt->bind_param("i", $msgid) or die(htmlspecialchars($stmt->error));
    $stmt->execute() or die(htmlspecialchars($stmt->error));
    $stmt->bind_result($message, $status, $vars) or die($stmt->error);
    $stmt->fetch() or die($stmt->error);
    $stmt->close();
    $image = ($status == -1) ? "fail" : "success";
    if (isset($vars) && !empty($vars)) {
        if (strpos($vars, ",")) {
            $vars = explode(",", $vars);
            foreach ($vars as $key => $var) {
                $this->filter($message, $var, <HERE MUST BE DEFINED VALUE>);
            }
        } else {
            $var = trim($vars);
            $this->filter($message, $var, <HERE MUST BE DEFINED VALUE>);
        }
    }
    $data = array(
        'status' => $status,
        'message' => $message
    );
}
protected function filter($content, $needle, $replacement) {
    return str_replace("%'.$needle.'%", $replacement, $content);
}
                If I got your question right. This should help.
<?php
    define('TEST', 'abc');
    echo constant('TEST');
http://www.php.net/manual/en/function.constant.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With