// * SELECTING ALL POSTS.
public static function selectAllPosts() {
$query = Database::Connect()->prepare("SELECT * FROM posts");
$query->execute();
$recipe = $query->fetch(\PDO::FETCH_OBJ);
// THIS IS THE TARGET.
$recipeImage = $recipe->recipe_image;
return true;
}
// THIS IS ANOTHER PHP FILE.
$recipe_image = Posts::selectAllPosts()->$recipeImage ?? "default-recipe-
picture.png";
Я ожидаю, что $ recipeImage будет доступен из другого файла.