// * 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可以从另一个文件访问。
答案 0 :(得分:0)
不可能在函数内部访问变量。