2

Before I remembered how to accomplish what I was doing, I tried a couple different things, kind of just hacking at it.
What I was trying to accomplish was to set the following string as a variable and then echo it out in a batch script:

<?php require('__php__.php'); ?>

I eventually worked it out with help from SO, but before I got there, I tried this (for some reason):

 set (phpStr=<? php require('__php__.php'); ?>)

Which I realize doesn't make any sense. However, how the cmd shell interpreted what I wanted to do was as follows:

 set (phpStr= php require('__php__.php'); ? 0<? 1>)

In other words, when I typed the code in the second code block above, and turned on echo in the script, what showed up in the cmd shell was the command in the third code block. Then there was a syntax error, and the script exited.

Can anyone explain what happened? (Not why it didn't work. That is obvious to me, but rather, how it arrived at the interpretation it did. It's a pretty awesome restructuring of the original command. I just can't figure out how it got there.)

4

1 回答 1

0

您需要转义重定向和其他有毒字符,^否则重定向将处于活动状态并尝试创建文件等%是一种特殊情况。

你也可以使用这样的东西:

@echo off
for /f "delims=" %%a in ("<?php require('__php__.php'); ?>") do echo %%a
于 2013-08-25T03:35:44.783 回答