带有PHP语法的问题

I need a simple php function to mimic an Ajax form submission - basically in the form there is a radio button "ajax" and it is either set to yes or no. I just need to mimic successful/failing ajax calls...

HTML

<label for="">Ajax Success*<input type="radio" name="ajax" id="yes" value="yes" checked>Yes<input type="radio" name="ajax" id="no" value="no">No</label>

PHP

<?php
    $ajax = $_POST["ajax"];
    if(isset($_POST['ajax'] == "yes"))  {
        echo "success";
    } else {
        echo "failure";
    }
?>

if I remove the isset, I get an 'undefined index' error, if I put it in I get a syntax error but it looks correct to me...

I just need to send back an echo depending on what option is selected for the input 'ajax'

thx

isset($_POST['ajax'] == "yes") doesn't make sense. You want to check if it's set, and then check if its value is equal to "yes":

if(isset($_POST['ajax']) && $_POST['ajax'] == "yes") {
    echo "success";
} else {
    echo "failure";
}

As your code does, I'll say you use your defined variable like in this example:

<?php
    $ajax = $_POST["ajax"];
    if($ajax == "yes")  {
        echo "success";
    } else {
        echo "failure";
    }
?>

Because if the variable has the value "yes" it'll be ok and undefined or other value will end in "failure".