Replace static text in multiple files

Asked

Viewed 271 times

0

I have a static site and I am implementing some functions in php in it and one of them is to include a menu on all pages, the same is already created and all files are with it.

What I want is this: replace all this code with: include menu.php

Is there a tool where I can do this? Since the menu code is the same for all files.

  • Your editor’s search/replace function does not resolve?

  • @bfavaretto I could not find a function that overwrites in all files.

  • Try the Sublime Text, he does that.

  • Notepad++ also does this, Brackets does, the command sed also, the options are several.

  • Thanks a lot, I downloaded the sublime here and managed to change, thank you very much!

1 answer

2

I don’t know any tools to do this, what you can do is copy the menu snippet - if it’s in HTML5, from<nav> to </nav>- and put in a. php file if the menu is dynamic (i.e., requires back-end processing) or . php or . html if the menu is static (no need for Back-end processing) and use the include tag:

<?php 
   include("pasta/nomearquivo"); 
?>

Being "filename" the file name and "folder" if the menu file is not in the main directory but in a subdirectory inside it, otherwise use:

<?php
   include("nomearquivo");
?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.