Jump to content

Internal class method call - undefined?


Recommended Posts

Fatal error: Call to undefined function getDB() in C:\...\xampp\htdocs\DAL.php  on line 10

 

test.php

include 'DAL.php';

$DALClass = new DAL();

if($results = $DALClass->getData()){
...
}

 

DAL.php

<?php
class DAL {

function getDB(){	
	return $mysqli = new mysqli('localhost','root','','mytest');	
}

public function getData(){

	$db = getDB();
	return $result = $db->query("select * from tbl_main");	
} 
}
?>

 

I'm coming from another coding platform and trying to replicate my knowledge in PHP.

Link to comment
https://forums.phpfreaks.com/topic/203543-internal-class-method-call-undefined/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.