php another page function

Asked

Viewed 831 times

1

This is code on another php page I try to call the functions but give error as if the variable did not exist , someone has some 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;
}

1 answer

0

try like 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'];
}
  • valeuzao!!!!!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.