有时我发现自己处于一种情况,我想为border元素的左侧和右侧定义规则。但老实说,border-left: solid 1px #999; border-right: solid 1px #999有点笨拙。它浪费空间,我必须应用更改两次,而且它的渲染效率可能会也可能不会降低。
有没有办法一次性定义水平边界或垂直边界?
我试过这个:
$mtcDatum = preg_match("/[0-9]{2}/[0-9]{2}/[0-9]{4}/", $lnURL);
Run Code Online (Sandbox Code Playgroud)
这会返回一条错误消息:
警告:preg_match()[function.preg-match]:未知修饰符'['
为什么这不起作用?我已经习惯了Linux的正则表达式,PHP处理正则表达式的方式有何不同?
我有以下代码:
int main() {
char *sPPhrase[51];
/* Input */
printf("Enter string (max. 50 chars):\n");
fflush(stdout); /* Works around an annoying Eclipse bug that fails to display the output from the printf command */
scanf("%s", *sPPhrase); /* Won't work */
/* More code goes here */
}
Run Code Online (Sandbox Code Playgroud)
该scanf()命令失败,我想,是因为*sPPhrase不可写的sPPhrase指向一个字符串常量.编译器没有任何错误的线索.稍后,我需要将此字符串传递给此函数:
char* reverse(char* sPPhrase[]);
字符串常量不可写,但我需要将此char*传递给此函数.如何重写我的代码以使其工作?
我试图通过这样做来读取文件中的最后50个字符:
FILE* fptIn;
char sLine[51];
if ((fptIn = fopen("input.txt", "rb")) == NULL) {
printf("Coudln't access input.txt.\n");
exit(0);
}
if (fseek(fptIn, 50, SEEK_END) != 0) {
perror("Failed");
fclose(fptIn);
exit(0);
}
fgets(sLine, 50, fptIn);
printf("%s", sLine);
Run Code Online (Sandbox Code Playgroud)
这不会返回任何有意义的东西.为什么?
我试图通过使用jQuery的.width()函数来访问某些元素的宽度,但有时返回值是0我不期望它的时候.这是一个已知的问题?为什么元素必须可见才能工作?如果有限制,我该如何解决它们?