1
この関数は、データベースから行を返し、ブラウザに出力します。関数からPDOを呼び出します。
<?php
$an_int = 12;
// If this is an integer
if (is_int($an_int))
{
$conn = new PDO('mysql:host=localhost;dbname=pushchat', 'pushchat', 'd]682\#%yI1nb3');
global $conn;
$stmt = $conn->prepare("SELECT IdPhoto, device_token, IdUser FROM photos ORDER BY IdPhoto DESC LIMIT 300 ");
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
print_r($result);
}
?>
上記のコードを標準機能からどのように呼び出すことができますか?現在、ブラウザはまだ何も出力していません。
<?php
function new_function()
{
$an_int = 12;
// If this is an integer
if (is_int($an_int))
{
$conn = new PDO('mysql:host=localhost;dbname=pushchat', 'pushchat', 'd]682\#%yI1nb3');
global $conn;
$stmt = $conn->prepare("SELECT IdPhoto, device_token, IdUser FROM photos ORDER BY IdPhoto DESC LIMIT 300 ");
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
print_r($result);
}
}
new_function();
?>
この現在の構文では、ブラウザに出力が表示されません。 new_function
機能の中からオリジナルのコードを呼び出す方法はありますか?