是否有一种常见的方法来编码和解码任意数据,因此编码的最终结果只包含数字 - 如base64_encode但没有字母?
虚构的例子:
$encoded = numbers_encode("Mary had a little lamb");
echo $encoded; // outputs e.g. 12238433742239423742322 (fictitious result)
$decoded = numbers_decode("12238433742239423742322");
echo $decoded; // outputs "Mary had a little lamb"
Run Code Online (Sandbox Code Playgroud) 想知道是否有人知道这些方法中的任何一种是否会更快地产生输出:
Method 1
for ($i=1;$i<99999;$i++) {
echo $i, '<br>';
}
Run Code Online (Sandbox Code Playgroud)
要么
Method 2
for ($i=1;$i<99999;$i++) {
$string .= $i . '<br>';
}
echo $string;
Run Code Online (Sandbox Code Playgroud)
感谢您的任何输入.
当我遇到它时,我忘记了铸造机制:).那么你能让我再次记住它吗?因为目前看来我不能接受.
我是WPF的新手.我试图理解MouseDownEvent和PreviewMouseDownEvent之间的区别.
我理解WPF事件策略,我理解MouseDown事件是一个冒泡事件,PreviewMouseDown是一个隧道事件.
我也理解这些事件被触发的顺序 - 根据MSDN概述http://msdn.microsoft.com/en-us/library/ms742806.aspx#routing(这里有一个示例图).
所以我试着编写一些自己的代码,例如检查一下:
<Grid x:Name="grid" Width="250">
<StackPanel Mouse.MouseDown="StackPanel_MouseDown" PreviewMouseDown="StackPanel_PreviewMouseDown">
<WPFVisualizerExample:MyButton x:Name="B1" PreviewMouseDown="B1_PreviewMouseDown" MouseDown="B1_MouseDown" Margin="5,5,5,5">
<WPFVisualizerExample:MyButton x:Name="B2" PreviewMouseDown="B2_PreviewMouseDown" MouseDown="B2_MouseDown" Margin="5,5,5,5">
<WPFVisualizerExample:MyButton x:Name="B3" PreviewMouseDown="B3_PreviewMouseDown" MouseDown="B3_MouseDown" Margin="5,5,5,5">Click Me</WPFVisualizerExample:MyButton>
</WPFVisualizerExample:MyButton>
</WPFVisualizerExample:MyButton>
</StackPanel>
</Grid>
Run Code Online (Sandbox Code Playgroud)
我为每个事件(预览和非预览)都有一个事件处理程序,我想看看发生了什么,抛出了哪个事件(我为每个事件显示了一个消息框).
'MyButton'用户控件只是扩展基本Button并覆盖OnMouseDown和OnPreviewMouseDown来设置e.Handled false:
protected override void OnMouseDown(System.Windows.Input.MouseButtonEventArgs e)
{
base.OnMouseDown(e);
e.Handled = false;
}
protected override void OnPreviewMouseDown(System.Windows.Input.MouseButtonEventArgs e)
{
base.OnPreviewMouseDown(e);
e.Handled = false;
}
Run Code Online (Sandbox Code Playgroud)
(试过这个,没有这个).
根据MSDN概述(在上面的链接中),如果我有3个元素,那么事件路由应该如下:
根元素上的PreviewMouseDown(隧道).
中间元素#1上的PreviewMouseDown(隧道).
源元素#2上的PreviewMouseDown(隧道).
源元素#2上的MouseDown(气泡).
MouseDown(气泡)在中间元素#1上.
根元素上的MouseDown(气泡).
所以我希望根据上面的内容显示消息框.出于某种原因 - 我不明白只会抛出预览事件(根据MSDN所说的Preview_B1 => Preview_B2 => Preview_B3).我的期望是:Preview_B1 => Preview_B2 …
我希望有人可以帮助我,因为我不知所措.我试图在运行时使用jquery简单地将纯文本文件加载到页面中 - 在IE8(8.0.7600.16385),Firefox 3.6.3中一切正常,但是在Google Chrome 5.0.375.55中,"数据"无效 - 我得到一个空警报框.
这是我正在使用的代码;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Animation Test</title>
<script type="text/javascript" language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function () {
$.ajax({
url: 'level1.txt',
success: function (data) {
alert(data);
},
async: true,
type: 'GET'
});
});
</script>
</head>
<body>
<canvas id="canvas" width="640" height="480">
Unsupported Browser
</canvas>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我正在加载的文件是包含此文件的纯文本文件;
Central Cavern
100
O.........1.C....C...........1.O
O................1.............O
O..............................O
O..............................O
O......................B1..B...O
O=============~~~~=~~~~========O
O.............................1O
O===...........................O
O............A..OOO.B..........O
O====...<<<<<<<<<<<<<<<<<<<<...O
O............................==O
O..............................O
O..........B........OOO.....===O
O....===============...........O
O%............................XO
O==============================O
Run Code Online (Sandbox Code Playgroud)
(是的 …
我有一个问题是我的一个元素100%在100%的整体布局中.
我尝试了不同的定位解决方案,我最终得到隐藏的内容,底部的页脚后面的浮动,或内容最终在页脚后面,并在页脚后继续.
这是我对页面布局的看法.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<style>
*{margin:0}
html,body{margin:0; padding:0; height:100%}
.wrapper{position:relative; margin:0 auto -200px; height:auto !important; height:100%; min-height:100%}
.container{width:930px; margin:0 auto; text-align:left}
.right{float:right; width:680px; background:#FFF; margin:60px 10px 0 0; padding:0}
.left{float:left; width:240px}
.content{padding:10px}
.footer{position:absolute; width:100%}
.footer,.push{height:200px}
</style>
</head>
<body>
<div class="wrapper">
<div class="container">
<div id="left">
left
</div>
<div class="right">
<div class="content">
content
</div>
</div>
<div class="push"></div>
</div>
<div class="footer">
footer
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
页面布局为100%高度和页脚底部的布局使其只是具有类名称内容的div,我希望100%也是如此,如果内容到达页脚而不是消失,则将页脚向下推进.
任何帮助最受赞赏.
我试图使用gmaps V3提供的地址组件类型获取国家名称.
我不知道我怎么能以正确的方式得到它.. http://code.google.com/apis/maps/documentation/javascript/services.html#GeocodingAddressTypes
我想在这里提醒国家名字:
警报(结果[1] .address_component [国家]);
这里是代码..任何帮助都非常感谢..谢谢
function codeLatLng() {
var input = document.getElementById("latlng").value;
var latlngStr = input.split(",",2);
var lat = parseFloat(latlngStr[0]);
var lng = parseFloat(latlngStr[1]);
var latlng = new google.maps.LatLng(lat, lng);
if (geocoder) {
geocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
alert(results[1].address_component[country]);
} else {
alert("No results found");
}
} else {
alert("Geocoder failed due to: " + status);
}
});
}
}
Run Code Online (Sandbox Code Playgroud) 我按照这个在我的Ubuntu机器上获得F#.然而,它给我一个错误,说
- 使用mono.snk重新调用FSharp.Core.dll ./install-mono.sh:24:sn:not found - 将FSharp DLLS安装到GAC中将程序集bin/FSharp.Core.dll添加到缓存中:强名称无法验证延迟签名的程序集
我有一个函数,我提供了一个指向std :: vector的指针.
我想让x = to vector [element]但是我遇到了编译器错误.
我正在做:
void Function(std::vector<int> *input)
{
int a;
a = *input[0];
}
Run Code Online (Sandbox Code Playgroud)
这样做的正确方法是什么?谢谢