English 中文(简体)
作出声明,如果在一行发言,
原标题:make an ifnot statement and if statement in one line

我试图作两点发言。 如果一个变量是NOT的现存和安放,NOT与“Good2go”一词相对应,而另一个可以核查确保“人”变数。 我试图在此传递错误信息。 这里是我掌握的,也是我所尝试的,看来没有任何工作。

if (stripos($_POST[ check ],  good2go ) == FALSE && $_POST[ body ]) {        
                $error = true; } 

if (!$_POST[ check ] ==  good2go  && $_POST[ body ]) {  
                $error = true; }

if (!stripos($_POST[ check ],  good2go ) && $_POST[ body ]) {   
                $error = true; }

if ((!stripos($_POST[ check ],  good2go )) && $_POST[ body ]) { 
                $error = true; }

我如何做到这一点?

页: 1 php有审定代码和电子邮件代码。

    $error = false;
  if (isset($_GET[ action ]) && ($_GET[ action ] ==  send )) {

          // Winnie the pooh check
         //$t = tep_db_prepare_input($_POST[ verify ]);
         if (!isset($_POST[ check ]) && !$_POST[ check ]== good2go  && isset($_POST[ body ])) {
                $error = true;              
        } else  {  // Winnie the pooh Check

    $name = tep_db_prepare_input($_POST[ name ]);
    $email_address = tep_db_prepare_input($_POST[ email ]);


//IP recorder start
$ipaddress = $_SERVER["REMOTE_ADDR"];
$ip = "

IP: " . $ipaddress;
$content = "

Name: ".$name."

Comments: ".$_POST[ enquiry ];
$product = tep_db_prepare_input($_POST[ product ]);
    if ($product) { 
$product_text = "

Product Interest: ".$product; }
$content_ip = $content . $product_text. $ip;
$enquiry = tep_db_prepare_input($content_ip);
//IP recorder end


        }
 // BOF: Remove blank emails
// if (tep_validate_email($email_address)) {
// tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $enquiry, $name, $email_address);
// tep_redirect(tep_href_link(FILENAME_CONTACT_US,  action=success ));
// } else {
// $error = true;
// $messageStack->add( contact , ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
    if (! tep_validate_email($email_address)) {
        $error = true;
        $messageStack->add( contact , ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
    }
    if ($enquiry ==   ) {
        $error = true;
        $messageStack->add( contact , ENTRY_EMAIL_CONTENT_CHECK_ERROR);
    }
    if ($error == false) {      
      tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, EMAIL_SUBJECT, $enquiry, $name, $email_address);

      tep_redirect(tep_href_link(FILENAME_CONTACT_US,  action=success ));
// EOF: Remove blank emails
    }
  }
最佳回答

3. 解决你最新的问题:

if (!isset($_POST[ check ]) || !$_POST[ check ]== good2go  || !isset($_POST[ body ])) {
                $error = true;              
} 

管道和营地的理由是,如果纽约的田地有问题,你想要留下错误。 另外,你还要检查一下,是否是NOT的定点。 Gla!

问题回答

而确保“人”变数的制衡办法则不存在。

if(stripos($_POST[ check ], "good2go") !== false && !isset($_POST[ body ])){
    //code here
}

如果一个变量存在,则进行核对;与“货物”一词相对应。

isset($_POST[ check ]) AND $_POST[ check ] ==  good2go 

而确保“人”变数的制衡办法则不存在。

!isset($_POST[ body ])

这样,就把他们聚集在一起。

if (isset($_POST[ check ]) AND $_POST[ check ] ==  good2go  AND !isset($_POST[ body ])) {        
  $error = true; 
} 

尝试:

if(!empty($_POST[ check ]) && $_POST[ check ]== good2go  && empty($_POST[ body ])) { $error=true; }

考虑使用<条码>,代之以<条码>。

不需要所有这些不需要的职能。 你们试图实现的是:

if (isset($_POST[ check ]) && $_POST[ check ]== good2go  && !isset($_POST[ body ]) {
   // your code 
}

然而,As per name of the question: 采用替代声明。 Syn

$var = <condition> ? <true> : <false>;




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签