php another page function [duplicate]

1

This is a code on another php page I try to call the functions but they give error as if the variable did not exist, does anyone have any idea?

<?php
$host = "host";
$port = 587;
$username= 'usuario';
$password = 'senha';
$secure = 'tls';
$from = '[email protected]';

function host()
{

    return $host;
}
function port()
{
    return $port;
}
function user()
{
    return $username;
}
function secure()
{
    return $secure;
}
function password()
{
    return $password;
}
function from()
{
    return $from;
}
    
asked by anonymous 13.03.2017 / 18:53

1 answer

0

try this:

<?php
$GLOBALS['host'] = "host";
$GLOBALS['port'] = 587;
$GLOBALS['username'] = 'usuario';
$GLOBALS['password'] = 'senha';
$GLOBALS['secure'] = 'tls';
$GLOBALS['from'] = '[email protected]';

function host()
{

    return $GLOBALS['host'];
}
function port()
{
    return $GLOBALS['port'];
}
function user()
{
    return $GLOBALS['username'];
}
function secure()
{
    return $GLOBALS['secure'];
}
function password()
{
    return $GLOBALS['password'];
}
function from()
{
    return $GLOBALS['from'];
}
    
13.03.2017 / 18:54