Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4618564
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:17:06+00:00 2026-05-22T02:17:06+00:00

How to change all the occurrence of the <script> <Script> <scRipT> <sCrIpT> and so

  • 0

How to change all the occurrence of the <script> <Script> <scRipT> <sCrIpT> and so .. to &lt;script&gt; &lt;Script&gt; with PHP
I also want to remove

The input will be taken from a WYSIWYG Editor, so i can not use the strip_tags function.

Edit 2
Is there any other way a user can execute a javascript with some kind of strange characters to
I found this on internet

<scr<!--*-->ipt>
alert('hi')
</script>

But it did not worked though, is there any such possibilities ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:17:07+00:00Added an answer on May 22, 2026 at 2:17 am

    Probably the simplest method would be str_ireplace() for case-insensitive replacement, however this won’t preserve the case of the “sCriPt” word. But if you’re out to de-fang XSS attacks that may be just fine:

    str_ireplace("<script>", "&lt;script&gt;", $input);
    

    A more complex solution could be devised with preg_replace() to preserve case, but would be slower. This might work, but if it were me I’d use str_ireplace()…

    preg_replace("/<(script)>/i", "&lt;$1&gt;", $input);
    

    Note: If it is XSS prevention you’re after, neither of these takes into account things like <script type=text/javascript>. To truly handle these cases, you need to load the HTML string into DOMDocument and delete the offending script nodes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I want to write a regular expression to change all <abc> ,
I know that by typing the following: :%s/iwanthis/replacedbythis/g will change all the matching words
I need change background of all text that have two spaces from the start
All I want is to be able to change the color of a bullet
Hey all, I want to change a value in a table (in a mysql
I have a website directory where I need to change all hardcoded links from
I have multiple virtual hosts running PHP 5.2.17. Periodically a script will seemingly randomly
Change all links that have an image in it to: javascript(alert(thehref)); eg. <a href=/galleries/anna-leah-111827/image01.html><img
Is there a relatively simple way to change all the data in a JTable?
I'm attempting to use the #define directive to change all of ulong to unsigned

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.