I have a HTML file, which contains many href=""
, src=""
attributes, and I need to use PHP to read in the whole HTML file, then use PHP code to replace all the value of href=""
, src=""
to the ones I want. I think the steps are:
- use
file_get_contents()
to read theabc.html
file and save it into a variable - About the
href=""
,src=""
value replacing part, is it better to use string replace functions or use regular expression? - echo the final variable(the updated HTML).