18.11.2016, 20:30
Quote:
What if you change use ($mysql) to use (&$mysql)?
The object example: PHP код:
|
Note: Altho hmm seems that I even get a problem with that
Код:
Fatal error: Call to undefined method stdClass::function()
PHP код:
<?php
include "core/bootstrap.php";
$testObject = new stdClass;
$testObject->pass = '';
$testObject->function = function() {
echo $this->pass;
};
Event::on("GameModeInit", function() use ($testObject) {
$testObject->function();
});
?>
@amirm how did you get the mysqli to work? I tried with mysqli_connect but seems that I get undefined symbol for it
PHP код:
<?php
include "core/bootstrap.php";
$mysql = null;
Event::on("GameModeInit", function() use (&$mysql) {
$mysql = mysqli_connect("localhost", "root", "", "roleplay");
if($mysql == true) {
echo "Hello world";
}
});
?>