GetCategories.php
<?php
require_once "Connection.php";
$query = mysqli_query($connection, "SELECT * FROM CATEGORIES");
$array = array();
while ($row = mysqli_fetch_assoc($query))
$array[] = $row;
//Execute this code only if was loaded directly
echo json_encode($array, JSON_NUMERIC_CHECK);
Is there any way to know if the GetCategories.php
file was included or loaded directly?
I found a lot of similar questions but can't find any helpful answers.