Headers already sent - characters after ?> in every single file (thousands) - is there a way to quickly delete the extra characters?

StackOverflow https://stackoverflow.com/questions/23085167

  •  04-07-2023
  •  | 
  •  

Вопрос

As in the title, I have thousands of files (UTF-8) which for some reason have inherited two carriage returns after the end of the PHP code. This is causing "header already sent" errors in my program.

I have tried finding/replacing with Notepad++ but I don't know how to define a carriage space. Is there any way I can use a program to go through each file and replace:

"?>

"

with:

"?>"

Thanks in advance!

Это было полезно?

Решение

Step 1:

Select your "Find" text like this:

enter image description here

Step 2: Press CTRL + H and enter your replacement text:

enter image description here

Step 3: Press Replace All button:

enter image description here

As you can see, it does work. You can use the "Find in Files" to batch this operation also against many files, without having to do one by one manually.

Другие советы

Err, this is not really a coding question and will probably be closed soon, but nevertheless here's how you do it:

  1. On Notepad++, press Ctrl+F
  2. Select the Replace tab
  3. Under Search mode check the radio button: Extended (\n,\r,\t...)
  4. Search for string "<?\r\n\r\n" and replace with "?>"

Have a try with:

Find what: "?>\R+"
Replace with: "?>"

Select Regular expression and click on Replace All

\R stands for any of \n, \r\n or \r.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top