"成功"のために、次のコードで定義されていない定数エラーが発生します。未定義の定数エラーPHP
if(success)
{
echo "<script type=\"text/javascript\">".
"alert('Form submitted successfully.');".
"</script>";
}
誰でもこの問題の解決にお手伝いできますか? $成功へ
"成功"のために、次のコードで定義されていない定数エラーが発生します。未定義の定数エラーPHP
if(success)
{
echo "<script type=\"text/javascript\">".
"alert('Form submitted successfully.');".
"</script>";
}
誰でもこの問題の解決にお手伝いできますか? $成功へ
お読みくださいDOC http://php.net/manual/en/language.constants.php
あなたのコードは次のようにする必要があり
define('success', true);
if(success)
{
echo "<script type=\"text/javascript\">".
"alert('Form submitted successfully.');".
"</script>";
}
をや変数を使用する(あなたは定数を使用したい場合)http://php.net/manual/en/language.variables.basics.php
このような構造を持つユースケースは何ですか?コードの実行を避けるために '成功'を 'false'と定義することができますか? ;-P –
変更成功
if($success)
{
echo "<script type=\"text/javascript\">".
"alert('Form submitted successfully.');".
"</script>";
}
未定義の変数 –
@nicholas Nicolaouコード全体を表示できますか? –
以下のコードを試してください。
$success = "test"; // set your value that you can get.
if(isset($success) && $success != "")
{
echo "<script type=\"text/javascript\">".
"alert('Form submitted successfully.');".
"</script>";
}
$を使用しないと「成功」は変数ではなく定数です。この定数は、ifでチェックされる値で初期化されません。
あなたの変数はあなたに設定する必要があります。if-clause
に行ってください。 あなたのケースでは、変数が真であるかどうかを確認したいし、それがコンテンツにForm submitted successfully.
をalert()
必要がありますので、変数を設定するには2つの方法があるかどうか。
define("success", true)
関数で定数を定義します。その後、コードをそのまま使用することができます。$success = true;
を定義します。
<?php
$success = true; // define the variable and set it to true
if ($success) {
echo "<script type=\"text/javascript\">" .
"alert('Form submitted successfully.');" .
"</script>";
}
?>
または
<?php
$success = true; // define the variable and set it to true
if (isset($success) && !empty($success) && $success != false) {
echo "<script type=\"text/javascript\">" .
"alert('Form submitted successfully.');" .
"</script>";
}
?>
'SUCCESS'は何の変数あなたはありません'$ success'をして、その変数が真であるかどうかを確認してください。 – Blueblazer172
私はあなたがワロンだと思います'PHP'と' JavaScript'を混在させます。 – Ionut
あなたは成功を教えてください。 –