我有一个php文件启动我的exe.exe执行cout并且文本以html格式打印,这一切都很好.直到我写"someline \n"; \n打破输出,我只看到最后一行.如何打印/回显其中包含多行的文本/字符串?
当前的粘贴已经注释掉,我的文本打印正常.它在控制台看起来很丑陋,当我用IE7查看源码时(虽然我主要用FF浏览),看起来很痛苦.这是我目前的php和cpp文件
<html>
<head>
</head>
<body>
<?php
echo( exec('c:/path/to/exe/launchMe.exe hey lol hi') );
?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
CPP
#include <string>
#include <iostream>
#include <sstream>
using namespace std;
const string htmlLine(string s)
{
s+= "<br />";
// s += "\n";
return s;
}
int main(int argc, char *argv[])
{
stringstream s;
s << argc;
cout << htmlLine("woot") << htmlLine(s.str());
for (int i=0; i<argc; ++i)
{
s.str("");
s << i << " = " << argv[i];
cout << htmlLine(s.str());
}
return …Run Code Online (Sandbox Code Playgroud) 当我使用以下echo语句时,我得到一个很好的输出,这是从这三个独立的echo语句中得到的结果:
echo AP $macaddr
echo noise floor $noise
echo $channel
Run Code Online (Sandbox Code Playgroud)
输出:
AP ac:67:06:30:eb:00,
noise floor -96
channel=1
Run Code Online (Sandbox Code Playgroud)
但是,当我将所有三个变为一个单独的'echo'语句时,如下所示,输出中断.
echo AP $macaddr noise floor $noise $channel
Run Code Online (Sandbox Code Playgroud)
输出:
channel=06:30:eb:00, noise floor -96
Run Code Online (Sandbox Code Playgroud)
在此输出中,我没有看到通道和MAC地址缺少其第一个八位字节中的两个.是什么造成的?怎么能避免这个?
我有这个回音,
echo "<a href = 'showdetails.php?name='$name'&type=movie'> </a>";
Run Code Online (Sandbox Code Playgroud)
这是有意为之,但如果
$name = Gulliver's Travels;
Run Code Online (Sandbox Code Playgroud)
例如,我只会在另一页中收到Gulliver.
有没有办法绕过这个?
谢谢,
Zenshi.
我试图在PHP中回应一个javascript警告消息,但我有问题,在PHP的's'中包含警报的's'.
代码看起来像这样>>
onclick="return confirm('Are you sure you want to delete this customer ?')"
Run Code Online (Sandbox Code Playgroud)
如果我使用
echo onclick="return confirm('Are you sure you want to delete this customer ?')"
Run Code Online (Sandbox Code Playgroud)
如果我使用的话,因为额外的's,我在Dreamweaver中遇到错误
echo'onclick ="return confirm("你确定要删除这个客户吗?")"';
我不再在php中出错,但它仍然不起作用,并且生成的html给了我一个重复的属性消息,因为它输出后会产生额外的"".
我是一名初学PHP程序员,我想知道我的代码出了什么问题.
以下是受影响地点的小摘录:
echo "<form action='?tab=4' name='toedit5' method='get'><input value='text' onblur='edit('toedit5')' /></form>";
Run Code Online (Sandbox Code Playgroud)
在Chrome的开发者工具中,form元素完全消失了,edit('toedit5')变成了edit(' toedit5').
该edit()功能不执行.
这一行代码有什么问题吗?否则就是外面的代码弄乱了它.对不起,我没有包含它,但我不知道要包含什么.如果您需要更多信息,请告诉我.
谢谢.
我得到的是这样的:
working_dir
|-- samples
|-- table1.tbl
|-- table2.tbl
|-- table3.tbl
Run Code Online (Sandbox Code Playgroud)
我想拥有的是这样的:
working_dir
|-- samples
| |-- table1.tbl
| |-- table2.tbl
| |-- table3.tbl
|-- table1.tbl
|-- table2.tbl
|-- table3.tbl
Run Code Online (Sandbox Code Playgroud)
samples目录中的.tbl文件将包含根目录中这些.tbl文件的前10行.
我试过了
for FILE in `ls *.tbl`; do
NEWFILE="samples/$FILE"
if [ ! -f "$NEWFILE" ] ; then
touch "$NEWFILE"
fi
echo `head $FILE` > $NEWFILE
done
Run Code Online (Sandbox Code Playgroud)
但是.tbl文件中的换行符samples丢失了,10行的内容被压缩到每个.tbl文件中的一行.
有帮助吗?谢谢.
我需要提取可以在一行中任何地方出现的序列号。序列号始终具有以下正则表达式格式:
S[XN]00-[0-9]{3}
Run Code Online (Sandbox Code Playgroud)
输出:
SX00-123
Run Code Online (Sandbox Code Playgroud)
我echo只想要这个。我可以grep使用序列号,并且正在考虑使用正则表达式,但不确定如何使用。
任何人都可以解释为什么这不能给出正确的答案?它与溢出有关吗?
$ echo $(((729669216169173060 * 256) + 73))
2327878602212787273
Run Code Online (Sandbox Code Playgroud)
但答案应该是186795319339308303433.
我试图在/ etc/profile中添加echo语句,但它们会执行.
示例:这是我写的
echo CURRENTYEAR="`/bin/date +%y`" >> /etc/profile
echo CURRENTWEEK="`/bin/date +%V` " >> /etc/profile
echo VERSION="$CURRENTYEAR"."$CURRENTWEEK" >> /etc/profile
echo export VERSION >> /etc/profile
echo export SVN_HOME="https://example.com/svn/road" >> /etc/profile
echo SVN_BRANCH="$SVN_HOME/branches/qa_weekly/$VERSION" >> /etc/profile
echo export SVN_TAG="https://example.cpm/svn/road/tags" >> /etc/profile
echo export SVN_TRUNK="https://example.com/svn/empire/trunk" >> /etc/profile
export PATH=$PATH:/road >> /etc/profile
export SVN_BRANCH
Run Code Online (Sandbox Code Playgroud)
结果:我得到了什么
CURRENTYEAR=15
CURRENTWEEK=33
VERSION=.
export VERSION
export SVN_HOME=https://example.com/svn/road
SVN_BRANCH=/branches/qa_weekly/
export SVN_TAG=https://example.com/svn/road/tags
export SVN_TRUNK=https://example.com/svn/road/trunk
Run Code Online (Sandbox Code Playgroud)
我希望它在/ etc/profile中如下所示
CURRENTYEAR=`/bin/date +%y`
CURRENTWEEK=`/bin/date +%V`
VERSION=$CURRENTYEAR"."$CURRENTWEEK
export VERSION
SVN_BRANCH=$SVN_HOME/branches/qa_weekly/$VERSION
SVN_TAG=$SVN_HOME/tags
SVN_TRUNK=$SVN_HOME/trunk
Run Code Online (Sandbox Code Playgroud)
提前致谢.
使用以下命令从Facebook Api中提取见解时,我得到6位小数.有人可以让我知道如何修改此命令只能获得1位小数.
echo '<td>'.$insight->cpm. '</td>';
Run Code Online (Sandbox Code Playgroud)