-2
<?php

$text = "<script>alert('hacked')</script>";

echo (strpos($text,'<script>'))  ? 'attention: js code detected' : 'NO js code';

NO js code why does it show me 'no js code' if i have '' tag?

usss123
  • 1
  • 2
  • 1
    Check `strpos($text,' – Nigel Ren Aug 16 '18 at 08:38
  • "doesn't work properly" is not a precise enough error description for us to help you. *What* doesn't work? *How* doesn't it work? What trouble do you have with your code? Do you get an error message? What is the error message? Is the result you are getting not the result you are expecting? What result do you expect and why, what is the result you are getting and how do the two differ? Is the behavior you are observing not the desired behavior? What is the desired behavior and why, what is the observed behavior, and in what way do they differ? – Jörg W Mittag Aug 16 '18 at 08:38
  • "PHP ternary operator doesn't work properly" – Please, think about this: you are claiming that a fundamental feature of a language used by millions of programmers every day doesn't work properly and that *you* are the only person in the world smart enough to have found this bug. Is that likely? Is it likely that a fundamental language feature is broken and nobody except you has noticed it? Or maybe, just maybe, there is a bug in your code, and you should rather spend your energy trying to find that bug instead of trying to find a bug in PHP. – Jörg W Mittag Aug 16 '18 at 08:42
  • Note: there *have* been cases of bugs in compilers and interpreters, and even in language specifications. I won't deny that. However, they are incredibly rare, and also usually incredibly obscure, otherwise someone else would have found them long before you. – Jörg W Mittag Aug 16 '18 at 08:43
  • Yeah my title isn't correct, i'll fix it – usss123 Aug 16 '18 at 08:49

1 Answers1

-1
   echo (strpos($text,'<script>') !== false)  ? 'attention: js code detected' : 'NO js code';
TsV
  • 629
  • 4
  • 7