我的网站现在变得足够大,我认为有必要将页面转换为php页面,以帮助我将来更新它.问题是:我的网站在网络上的各个网站上都有许多链接.例如,这些链接指向www.example.com/page1.html,但该页面现在将重命名为www.example.com/page1.php
人们如何解决这个问题?只需将html页面重定向到php页面?还有其他选择吗?这对SEO有什么影响吗?
谢谢
我刚刚推送了一个提交,然后意识到我需要更改提交消息。
所以在我的本地仓库中,我做了:
git commit --amend -m "New commit message"
Run Code Online (Sandbox Code Playgroud)
但是当我尝试推送这个时,我收到了大量错误消息说
Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull') and try again
Run Code Online (Sandbox Code Playgroud)
这是修改我的信息的错误方式吗?最后,我不得不重置我所有的 repos,然后用一条新消息再次提交。
所以我的问题是,修改已推送内容的提交消息的正确方法是什么?
我正在使用画布创建拖放系统。
canvas.addEventListener('mousedown', function () {
window.initialClickX = mouse.x;
window.initialClickY = mouse.y;
window.initialBallX = ball.x;
window.initialBallY = ball.y;
canvas.addEventListener('mousemove', onMouseMove, false);
}, false);
function onMouseMove(){
ball.x = mouse.x + window.initialBallX - window.initialClickX;
ball.y = mouse.y + window.initialBallY - window.initialClickY;
draw();
}
Run Code Online (Sandbox Code Playgroud)
当我单击时,我需要存储初始鼠标位置和初始球位置的值,以便我可以正确拖动球。
上面的代码工作得很好,但我认为所有全局变量看起来都很混乱。我希望 onMouseMove 能够接受参数initialClickX、initialClickY、initialBallX 和initialBallY。但是如何将这些参数添加到回调函数中呢?
或者如果有更好的方法请告诉我,谢谢。
我只是想知道如何使用变量名来在PHP中设置文件名?当我运行以下代码时:
<?php
if ($_POST) {
$filename = $_POST['firstName'];
header("Content-Type: application/txt");
header('Content-Disposition: attachment; filename="$filename.txt"');
echo "Welcome, ";
echo $_POST['firstName']. " " . $_POST['lastName'];
exit;
} else {
?>
<form action="" method="post">
First Name: <input type="text" name="firstName" /><br />
Last Name: <input type="text" name="lastName" /><br />
<input type="submit" name="submit" value="Submit me!" />
</form>
<?php } ?>
Run Code Online (Sandbox Code Playgroud)
文件名总是被设置为" $filename.txt",但我想它是Adam.txt,或Brian.txt等根据用户的输入.
我知道之前已经问了几次,但是在这种情况下解决方案似乎没有.基本上,我希望"play"这个词在这个按钮上垂直和水平居中.从横向上看,文本本身就是行为,但是纵向,无论我尝试什么,它总是比它应该低一点,在我测试它的所有浏览器中.有没有人有什么建议?谢谢
<style type="text/css">
button {
font-family: Verdana, Geneva, sans-serif;
color: white;
border-style: none;
vertical-align: center;
text-align: center;
}
button:hover {
cursor: pointer;
}
button::-moz-focus-inner /*Remove button padding in FF*/
{
border: 0;
padding: 0;
}
.start {
background-color: #0C0;
font-size: 2em;
padding: 10px;
}
</style>
<button type="button" class="start">play</button>
Run Code Online (Sandbox Code Playgroud) 我在使用jQuery按下提交按钮时向我的文档添加了一个h1标签.我想稍后与这个h1标签交互(用鼠标点击),所以我需要为它添加一个事件处理程序.但是,它似乎没有注册点击次数.
我之前看过这个问题,他们都说使用.on(),我有,但仍然没有运气.我没有收到任何错误,所以不知道从哪里开始.
这是一个非常简化版本的jsFiddle.谢谢.
$("h1").on("click", function(){
alert("test");
$("h1").css("color","red");
})
Run Code Online (Sandbox Code Playgroud) 从指定日期到现在,以年为单位获得数月的最有效方法是什么?
例如getMonths("August 2012")将输出
array(
array("Year"=>"2013", "months" = array(
"February", "January")
),
array("Year"=>"2012", "months" = array(
"December", "November","October", "September", "August")
)
)
Run Code Online (Sandbox Code Playgroud)
到目前为止我有:
$start = strtotime('2012-08-01');
$end = time();
$month = $start;
$months[] = date('F', $start);
while($month <= $end) {
$month = strtotime("+1 month", $month);
$months[] = date('F', $month);
}
Run Code Online (Sandbox Code Playgroud)
这是输出正确的月份,但不是将它们分组为几年.谢谢
在先前的堆栈溢出问题上,我发现了以下代码:
<script>
// this is to store a reference to the input so we can kill it later
var liveSource;
// creates an audiocontext and hooks up the audio input
function connectAudioInToSpeakers(){
var context = new webkitAudioContext();
navigator.webkitGetUserMedia({audio: true}, function(stream) {
console.log("Connected live audio input");
liveSource = context.createMediaStreamSource(stream);
liveSource.connect(context.destination);
console.log(liveSource);
});
}
// disconnects the audio input
function makeItStop(){
console.log("killing audio!");
liveSource.disconnect();
}
// run this when the page loads
connectAudioInToSpeakers();
</script>
Run Code Online (Sandbox Code Playgroud)
它从用户的麦克风获取音频并通过扬声器播放.我想要的是输入的水平(幅度)(例如,如果发生剪辑,我可以显示红色警告,或告诉用户他们需要说出来).在上面的代码中,我如何实际获取原始数据?
例如,如何将实际数字记录到控制台?我猜它都存储在liveSoure中?
我不需要任何聪明的画布动画等,只需要一个数字,告诉我输入的声音有多大.这个比较简单吗?如果是这样,它是如何完成的?
谢谢
我正在尝试使用 javascript 将路径元素附加到某些内联 svg,但收到错误:“Uncaught NotFoundError:尝试在不存在的上下文中引用节点”任何人都可以解释为什么这个 javascript无法使用我的 HTML?
<body>
<svg height='500' width='500'></svg>
<script>
var svg = document.getElementsByTagName("svg")[0];
var pathElement = svg.appendChild("path");
</script>
</body>
Run Code Online (Sandbox Code Playgroud) 如果我有一个字符串$myString = "apple, banana, cherry"
,我想将这些数据放入一个数组,那么我有两个选择.
$myArray = explode(", ", $myString)
Run Code Online (Sandbox Code Playgroud)
要么
$myArray = str_getcsv($myString)
Run Code Online (Sandbox Code Playgroud)
两者都给出相同的结果.
任何人都可以解释使用这些方法之一的优势/劣势吗?
我听说str_getcsv更好,根据php手册"因为explode()不会正确处理字符串或转义字符的可能封闭部分."
任何人都可以借助一个简单的例子来解释这意味着什么?
谢谢