返回列表 发帖
; cgi.fix_pathinfo = 0cgi.fix_pathinfo = 1
来自不同的文本?请按 a 文本 b 文本,及希望得到的c 文本,给出一个例子吧
bat小白,请多指教!谢谢!

TOP

本帖最后由 77七 于 2025-1-27 16:37 编辑

楼主应该不单单只替换某一个,而是一些吧?从楼主提供的文件中选取了写代码需要注意的行,还需要明确等号前后的空格需要保留原文本的格式,还是替换成新的固定格式?
  1. [PHP]
  2. ;;;;;;;;;;;
  3. ; Directive names are *case sensitive* - foo=bar is different from FOO=bar.
  4. ;
  5. ; |        bitwise OR
  6. ; &        bitwise AND
  7. ; !        boolean NOT
  8. engine = On
  9. ; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.
  10. precision    =  12
  11. ;output_handler =
  12. zlib.output_compression = Off
  13. ; *NOT* affected by whether Safe Mode is turned On or Off.
  14. ; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI.  PHP's
  15. ; cgi.fix_pathinfo=0
  16. ;fbsql.default_user = "_SYSTEM"
  17. soap.wsdl_cache_dir="/tmp"
复制代码
bat小白,请多指教!谢谢!

TOP

回复 27# piazini


   新年好!  代码前如果有其它代码 开启了延迟变量扩展,需关闭
  1. @echo off
  2. set "file=D:\php-5.2.9-Win32\php.ini-dist"
  3. rem a对应b,不需要空格
  4. set "#"a"=b"
  5. set "#"cgi.fix_pathinfo"=1"
  6. rem 替换为空值,则值为 / 在21行判断,如
  7. set "#"c"=/"
  8. (for /f "tokens=1* delims=:" %%a in ('findstr /n .* "%file%"') do (
  9. if "%%b" neq "" (
  10. for /f "delims==" %%c in (" %%b") do (
  11. for /f "tokens=1* delims=; " %%d in ("%%c") do (
  12. if defined #"%%d" (
  13. if "%%e" equ "" (
  14. for /f "tokens=* delims=; " %%f in (" %%b#") do (
  15. for /f "tokens=1* delims==" %%g in ("%%f") do (
  16. for /f "tokens=*" %%i in ("%%h") do (
  17. set str=%%f
  18. setlocal enabledelayedexpansion
  19. if "!#"%%d"!" equ "/" (
  20. echo=%%g=
  21. ) else (
  22. call echo=!str:%%i=%%#"%%d"%%!
  23. )
  24. endlocal
  25. set m_e=1
  26. )
  27. )
  28. )
  29. )
  30. )
  31. )
  32. )
  33. )
  34. if defined m_e (
  35. set m_e=
  36. ) else (
  37. echo=%%b
  38. )
  39. )) > "out.txt"
  40. rem move "out.txt" "%file%"
  41. pause
复制代码
bat小白,请多指教!谢谢!

TOP

回复 35# piazini


   setlocal和endlocal之间设置的变量为区域变量
bat小白,请多指教!谢谢!

TOP

回复 38# piazini


   如果用相对路径,检查下脚本的工作目录
bat小白,请多指教!谢谢!

TOP

返回列表