hello all, I do not know what i am doing wrong. When i run this if statement i get "Wrong!" all the time. Regards. if(trim(shell_exec('wmic diskdrive get model')) != "Model Maxtor 6Y080L0") { echo "Wrong!"; }else{ echo shell_exec('wmic diskdrive get model'); // Model Maxtor 6Y080L0 } PHP: i tried this way but still not working. $output = shell_exec('wmic diskdrive get model'); $newoutput = trim($output); $pieces = explode(" ", $newoutput, 2); echo $pieces[1]; // Maxtor 6Y080L0 if ($pieces[1] != "Maxtor 6Y080L0"){ echo "wrong"; PHP:
ok. the problem was the line break which you can not see on browser. but if you run the code on windows i got this: Model Maxtor 6Y080L0 but when i echo with php i had this output: Model Maxtor 6Y080L0 $output = shell_exec('wmic diskdrive get model'); $pieces = explode("\r\n", $output, 2); if (trim($pieces[1]) != "Maxtor 6Y080L0"){ echo "Wrong"; }else{ echo "OK."; } PHP:
For the next time, if you don't want this happening again, always make sure to view the page source, or put <pre> tags around your output so you'll see it as-is in the brwoser.