我不确定我是否误解了Javascript中的True/False是如何工作的.在我下面的Jquery脚本中,我将6个变量声明为false.如果正则表达式验证条件良好,那么我将变量重新声明为true.在底部是一个简单的alert()告诉我所有变量何时为真.
验证条件正在起作用(删除/添加类),但警报未显示.这就是为什么我不确定我是否搞乱了真假部分.
$('#password1').keyup(function() {
var checkLength = false;
var checkLetter = false;
var checkCaps = false;
var checkNum = false;
var checkSymbol = false;
var checkSpace = false;
var pswd = $(this).val();
//validate the length
if(pswd.length < 6 ){
$('#length').removeClass('valid').addClass('invalid');
}else{
$('#length').removeClass('invalid').addClass('valid');
checkLength = true;
}
//validate letter
if(pswd.match(/[A-Za-z]/)){
$('#letter').removeClass('invalid').addClass('valid');
}else{
$('#letter').removeClass('valid').addClass('invalid');
checkLetter = true;
}
//validate capital letter
if(pswd.match(/[A-Z]/)){
$('#capital').removeClass('invalid').addClass('valid');
}else{
$('#capital').removeClass('valid').addClass('invalid');
checkCaps = true;
}
//validate number
if(pswd.match(/\d/)){
$('#number').removeClass('invalid').addClass('valid');
}else{
$('#number').removeClass('valid').addClass('invalid');
checkNum = true;
}
//validate symbols
if(pswd.match(/[^a-zA-Z0-9]/)){ …
Run Code Online (Sandbox Code Playgroud) 我正在成功使用array_key_exists(),如php.net所述
例:
<?php
$search_array = array('first' => 1, 'second' => 4);
if (array_key_exists('first', $search_array)) {
echo "The 'first' element is in the array";
}
?>
Run Code Online (Sandbox Code Playgroud)
但是,取出值,它不起作用.
<?php
$search_array = array('first', 'second');
if (array_key_exists('first', $search_array)) {
echo "The 'first' element is in the array";
}
?>
Run Code Online (Sandbox Code Playgroud)
不确定如何仅仅按键来比较2个数组.
我正努力在tcpdf中获得准确的定位.我试图在多个地方使用SetMargins(),但我必须误解这个方法的用法.它似乎没有像我期望的那样工作.
$pdf->SetFont('helvetica', '', 12);
$pdf->AddPage();
$pdf->SetMargins(10, 10, 10, true); // set the margins
$html = 'Here is some text';
$pdf->writeHTMLCell(0, 0, '', '', $html, 'LRTB', 1, 0, true, 'L', true);
$pdf->SetMargins(0, 10, 0, true); // put space of 10 on top
$pdf->writeHTMLCell(0, 0, '', '', $html, 'LRTB', 1, 0, true, 'C', true);
$pdf->writeHTMLCell(0, 0, '', '', $html, 'LRTB', 1, 0, true, 'R', true);
$pdf->Output('example_002.pdf', 'I');
Run Code Online (Sandbox Code Playgroud)
我肯定得到一个输出,但我期待第一个和第二个writeHTMLCell()在它们之间重置空间.
http://www.tcpdf.org/doc/classTCPDF.html#ab3bbdb7c85ea08d175fd559be6132ba0
文档说第二个参数是上边距.
简而言之,如果有必要,我想弄清每一行的边距.但我可能正在使用错误的方法.我上面的例子似乎完全忽略了这个参数.但它似乎没有左右参数的问题.
我是通过命令行将文件ftp到另一台服务器.
要放置多个文件,我需要使用"mput"命令.
#ftp> mput *.php
Run Code Online (Sandbox Code Playgroud)
但是,它一直要求我验证是否要逐个放入每个文件.有没有强制推荐的选项?如果文件已经存在,还要强制覆盖远程服务器上的预先存在的文件?
我打算将返回的对象保存到文件中,以便以后下载进行审核.为了清楚起见,我正在使用外部API服务,并收集他们的数据,以便解析到另一个数据库.
这就是我所拥有的:
<?php
require('class.php');
$client = new connect2Them();
$logged_in = $client->login();
if(!$logged_in){
echo "Not connected!"; die();
}
$records = $client->get_records();
if(count($records < 1){
echo "No records found"; die();
}
$singlerecord = $records[0];
print_r($singlerecord);
?>
Run Code Online (Sandbox Code Playgroud)
print_r()工作正常,我收到了非常大量的数据.我正在通过命令行执行所有这些操作,因此我想将其保存到文本文件中.
我在$ singlerecord下面添加了这个:
<?php
$myFile = "reviewLater.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $singlerecord;
fwrite($fh, $stringData);
fclose($fh);
?>
Run Code Online (Sandbox Code Playgroud)
我从PHP得到这个错误: PHP警告:fwrite()期望参数2是字符串,对象在....
如何将print_r()放入reviewLater.txt?
在Eclipse中,当我运行代码时,这有效:
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
public class Main {
public static void main(String[] args) {
JFrame frame = new JFrame("test viewing images");
frame.setSize(600,300);
frame.setLocationRelativeTo(null); // centered on monitor
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
/**
* Menu Bar stuff
*/
JMenuBar menuBar;
JMenu menu;
JMenuItem menuItem;
// MENU BAR
menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);
menuBar.setVisible(true);
// MENU 1
menu = new JMenu("File");
menuBar.add(menu);
// MENU 1 ITEM
ImageIcon icon = new ImageIcon("src/Action-exit-icon.png");
menuItem = new JMenuItem("Exit Program", icon);
menu.add(menuItem); …
Run Code Online (Sandbox Code Playgroud) 我运行这个命令:
mysql> show status like '%onn%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| Aborted_connects | 0 |
| Connections | 37226 |
| Max_used_connections | 45 |
| Ssl_client_connects | 0 |
| Ssl_connect_renegotiates | 0 |
| Ssl_finished_connects | 0 |
| Threads_connected | 4 |
+--------------------------+-------+
Run Code Online (Sandbox Code Playgroud)
我知道我的网站流量不高,因此连接数让我感到困惑。我确信当我使用 PHP 时我会关闭所有连接。
连接数持续增长还有其他原因吗?
我正在通过我的代码来替换我正在使用ereg()函数的任何实例 - 我用它来匹配字符串中的正则表达式.
如果某人有比我正在使用的更好的方法,我可以使用一点方向.
function valid_currency($number){
if(ereg('^[0-9]+\.[0-9]{2}$', $number))
return true;
else
return false;
}
if(valid_currency(25.30)){
echo "valid currency";
}else{
echo "invalid currency string";
}
Run Code Online (Sandbox Code Playgroud)
我用preg_match()替换了ereg().
我现在收到此错误:
警告:preg_match()[function.preg-match]:没有结束分隔符'^'
我猜测正则表达式语法未被识别.从这里我有点卡住了.
我创建了一个简单的shell脚本:
#!/bin/bash
clear
echo "Starting Script now....."
echo "Write the info below to a new file in same directory...."
echo "name: John Smith"
echo "email: jsmith@demo.com
echo "gender: M"
echo
echo
echo "File is done"
Run Code Online (Sandbox Code Playgroud)
我想在同一目录中使用名称,电子邮件和性别详细信息创建一个文件.我不想从命令行这样做:
#./script.sh > my.config
Run Code Online (Sandbox Code Playgroud)
我宁愿在文件本身内做.
下面我使用PHP的imap库循环遍历电子邮件.它有效,但我一直坚持从邮件中保存附件.
<?php
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'someemail@somedomain.com';
$password = 'somepassword';
/* try to connect */
$imap_connection = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
/* grab emails */
$emails = imap_search($imap_connection,'ALL');
/* if emails are returned, cycle through each... */
if($emails) {
/* begin output var */
$output = '';
/* put the newest emails on top */
rsort($emails);
/* for every email... */
foreach($emails as $email_number) {
$structure = imap_fetchstructure($imap_connection,$email_number);
if(isset($structure->parts) && count($structure->parts)){
for($i = 0; …
Run Code Online (Sandbox Code Playgroud)