if(preg_match("/^\d*$/", "4312"))
{
echo "全数字
";
}
if(preg_match("/^[a-z]*$/i", "fdsFDfd"))
{
echo "全字母
";
}
if(preg_match("/^[a-z\d]*$/i", "fd4fd34"))
{
echo "有数字有字母
";
}
来自:http://www.yatan.com/group/topic.php?tid=21091
匹配所有中文字符的正则表达式是/[一-龥]/u,php代码如下。
要保存为utf-8编码
preg_match_all('/[一-龥]/u', '龥大家好一s々 Ⅳ 4 N ぁ Ψ Ж ㄩ ā 몸234adsf', $matchs);
print_r($matchs);
运行结果如下:
Array
(
[0] => Array
(
[0] => 龥
[1] => 大
[2] => 家
[3] => 好
[4] => 一
)
)
下面是匹配所有不包含某个字符串的正则表达式:
^(?!.*?word).*$
http://www.juyimeng.com/regular-expression-match-all-chinese-characters.html
网页制作中经常会在输出页面中插入空格,比如常见的登录页面,一般需要输入“用户名”“密码”,一般为了整齐好看都要在“密码”两个字中间插入空格,这个时候差别就出来了。
IE默认用英文字符来渲染符号,FF默认用中文字符渲染空格!也就是说你插3个空格在IE下面才能让“密 码”与“用户名”对齐,而在ff下只需2个空格,这就不能兼顾,总有个对不齐!
解决的方式很简单,就是在CSS中设置字体 font-family 就可以了
考虑了下,最终还是决定用pdo来操作sqlite3,因为技术上新的东西应该比旧的要好。pdo作为php的下一代标准数据接口会在php6中广泛应用,虽然php6正式发行版还遥遥无期。pdo的优势是很明显的,对于数据库的操作统一且易于数据库变动升级,而不需大面积修改源码。以前操作不同数据库需要用完全不同的函数,现在只需要在连接时用参数区分不同数据库,操作完全统一。至于sqlite2和3的区别并不了解,不过从sqlite3完全不向下兼容2,说明改动还是挺大的,应该有不少优势,只是我还不知道!
预定义常量:
The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.
PDO::PARAM_BOOL (integer) 表示一个布尔数据类型。 PDO::PARAM_NULL (integer)表示一个SQL NULL 数据类型。PDO::PARAM_INT (integer)表示一个SQL INTEGER 数据类型。PDO::PARAM_STR (integer)Represents the SQL CHAR, VARCHAR, or other string data type.PDO::PARAM_LOB (integer)Represents the SQL large object data type.PDO::PARAM_STMT (integer)表示一个记录集类型。当前无任何驱动支持。PDO::PARAM_INPUT_OUTPUT (integer)Specifies that the parameter is an INOUT parameter for a stored procedure. You must bitwise-OR this value with an explicit PDO::PARAM_* data type.PDO::FETCH_LAZY (integer)Specifies that the fetch method shall return each row as an object with variable names that correspond to the column names returned in the result set. PDO::FETCH_LAZY creates the object variable names as they are accessed.PDO::FETCH_ASSOC (integer)Specifies that the fetch method shall return each row as an array indexed by column name as returned in the corresponding result set. If the result set contains multiple columns with the same name, PDO::FETCH_ASSOC returns only a single value per column name.PDO::FETCH_NAMED (integer)Specifies that the fetch method shall return each row as an array indexed by column name as returned in the corresponding result set. If the result set contains multiple columns with the same name, PDO::FETCH_NAMED returns an array of values per column name.PDO::FETCH_NUM (integer)Specifies that the fetch method shall return each row as an array indexed by column number as returned in the corresponding result set, starting at column 0.PDO::FETCH_BOTH (integer)Specifies that the fetch method shall return each row as an array indexed by both column name and number as returned in the corresponding result set, starting at column 0.PDO::FETCH_OBJ (integer)Specifies that the fetch method shall return each row as an object with property names that correspond to the column names returned in the result set.PDO::FETCH_BOUND (integer)Specifies that the fetch method shall return TRUE and assign the values of the columns in the result set to the PHP variables to which they were bound with the PDOStatement::bindParam() or PDOStatement::bindColumn() methods.PDO::FETCH_COLUMN (integer)Specifies that the fetch method shall return only a single requested column from the next row in the result set.PDO::FETCH_CLASS (integer)Specifies that the fetch method shall return a new instance of the requested class, mapping the columns to named properties in the class.PDO::FETCH_INTO (integer)Specifies that the fetch method shall update an existing instance of the requested class, mapping the columns to named properties in the class.PDO::FETCH_FUNC (integer)PDO::FETCH_GROUP (integer)PDO::FETCH_UNIQUE (integer)PDO::FETCH_KEY_PAIR (integer)Fetch into an array where the 1st column is a key and all subsequent columns are valuesPDO::FETCH_CLASSTYPE (integer)PDO::FETCH_SERIALIZE (integer)As PDO::FETCH_INTO but object is provided as a serialized string. Available since PHP 5.1.0.PDO::FETCH_PROPS_LATE (integer)Available since PHP 5.2.0PDO::ATTR_AUTOCOMMIT (integer)If this value is FALSE, PDO attempts to disable autocommit so that the connection begins a transaction.PDO::ATTR_PREFETCH (integer)Setting the prefetch size allows you to balance speed against memory usage for your application. Not all database/driver combinations support setting of the prefetch size. A larger prefetch size results in increased performance at the cost of higher memory usage.PDO::ATTR_TIMEOUT (integer)Sets the timeout value in seconds for communications with the database.PDO::ATTR_ERRMODE (integer)See the Errors and error handling section for more information about this attribute.PDO::ATTR_SERVER_VERSION (integer)This is a read only attribute; it will return information about the version of the database server to which PDO is connected.PDO::ATTR_CLIENT_VERSION (integer)This is a read only attribute; it will return information about the version of the client libraries that the PDO driver is using.PDO::ATTR_SERVER_INFO (integer)This is a read only attribute; it will return some meta information about the database server to which PDO is connected.PDO::ATTR_CONNECTION_STATUS (integer)PDO::ATTR_CASE (integer)Force column names to a specific case specified by the PDO::CASE_* constants.PDO::ATTR_CURSOR_NAME (integer)Get or set the name to use for a cursor. Most useful when using scrollable cursors and positioned updates.PDO::ATTR_CURSOR (integer)Selects the cursor type. PDO currently supports either PDO::CURSOR_FWDONLY and PDO::CURSOR_SCROLL. Stick with PDO::CURSOR_FWDONLY unless you know that you need a scrollable cursor.PDO::ATTR_DRIVER_NAME (string)Returns the name of the driver.
Example #1 using PDO::ATTR_DRIVER_NAME<span style="color: #000000"><font style="background-color: #eeeeee"><span style="color: #0000bb"><?php</span><span style="color: #007700">if (</span><span style="color: #0000bb">$db</span><span style="color: #007700">-></span><span style="color: #0000bb">getAttribute</span><span style="color: #007700">(</span><span style="color: #0000bb">PDO</span><span style="color: #007700">::</span><span style="color: #0000bb">ATTR_DRIVER_NAME</span><span style="color: #007700">) == </span><span style="color: #dd0000">'mysql'</span></font><font style="background-color: #eeeeee"><span style="color: #007700">) {<br />
echo </span><span style="color: #dd0000">"Running on mysql; doing something mysql specific here\n"</span></font><font style="background-color: #eeeeee"><span style="color: #007700">;<br />
}</span><span style="color: #0000bb">?></span> </font></span>
PDO::ATTR_ORACLE_NULLS (integer)Convert empty strings to SQL NULL values on data fetches.PDO::ATTR_PERSISTENT (integer)Request a persistent connection, rather than creating a new connection. See Connections and Connection management for more information on this attribute.PDO::ATTR_STATEMENT_CLASS (integer)PDO::ATTR_FETCH_CATALOG_NAMES (integer)Prepend the containing catalog name to each column name returned in the result set. The catalog name and column name are separated by a decimal (.) character. Support of this attribute is at the driver level; it may not be supported by your driver.PDO::ATTR_FETCH_TABLE_NAMES (integer)Prepend the containing table name to each column name returned in the result set. The table name and column name are separated by a decimal (.) character. Support of this attribute is at the driver level; it may not be supported by your driver.PDO::ATTR_STRINGIFY_FETCHES (integer)PDO::ATTR_MAX_COLUMN_LEN (integer)PDO::ATTR_DEFAULT_FETCH_MODE (integer)Available since PHP 5.2.0PDO::ATTR_EMULATE_PREPARES (integer)Available since PHP 5.1.3.PDO::ERRMODE_SILENT (integer)Do not raise an error or exception if an error occurs. The developer is expected to explicitly check for errors. This is the default mode. See Errors and error handling for more information about this attribute.PDO::ERRMODE_WARNING (integer)Issue a PHP E_WARNING message if an error occurs. See Errors and error handling for more information about this attribute.PDO::ERRMODE_EXCEPTION (integer)Throw a PDOException if an error occurs. See Errors and error handling for more information about this attribute.PDO::CASE_NATURAL (integer)Leave column names as returned by the database driver.PDO::CASE_LOWER (integer)Force column names to lower case.PDO::CASE_UPPER (integer)Force column names to upper case.PDO::NULL_NATURAL (integer)PDO::NULL_EMPTY_STRING (integer)PDO::NULL_TO_STRING (integer)PDO::FETCH_ORI_NEXT (integer)Fetch the next row in the result set. Valid only for scrollable cursors.PDO::FETCH_ORI_PRIOR (integer)Fetch the previous row in the result set. Valid only for scrollable cursors.PDO::FETCH_ORI_FIRST (integer)Fetch the first row in the result set. Valid only for scrollable cursors.PDO::FETCH_ORI_LAST (integer)Fetch the last row in the result set. Valid only for scrollable cursors.PDO::FETCH_ORI_ABS (integer)Fetch the requested row by row number from the result set. Valid only for scrollable cursors.PDO::FETCH_ORI_REL (integer)Fetch the requested row by relative position from the current position of the cursor in the result set. Valid only for scrollable cursors.PDO::CURSOR_FWDONLY (integer)Create a PDOSt
atement object with a forward-only cursor. This is the default cursor choice, as it is the fastest and most common data access pattern in PHP.PDO::CURSOR_SCROLL (integer)Create a PDOStatement object with a scrollable cursor. Pass the PDO::FETCH_ORI_* constants to control the rows fetched from the result set.PDO::ERR_NONE (string)Corresponds to SQLSTATE '00000', meaning that the SQL statement was successfully issued with no errors or warnings. This constant is for your convenience when checking PDO::errorCode() or PDOStatement::errorCode() to determine if an error occurred. You will usually know if this is the case by examining the return code from the method that raised the error condition anyway.PDO::PARAM_EVT_ALLOC (integer)Allocation eventPDO::PARAM_EVT_FREE (integer)Deallocation eventPDO::PARAM_EVT_EXEC_PRE (integer)Event triggered prior to execution of a prepared statement.PDO::PARAM_EVT_EXEC_POST (integer)Event triggered subsequent to execution of a prepared statement.PDO::PARAM_EVT_FETCH_PRE (integer)Event triggered prior to fetching a result from a resultset.PDO::PARAM_EVT_FETCH_POST (integer)Event triggered subsequent to fetching a result from a resultset.PDO::PARAM_EVT_NORMALIZE (integer)Event triggered during bound parameter registration allowing the driver to normalize the parameter name.
准备用php+sqlite做个小东西,原计划用sqlite3,不过需要PDO扩展支持,不是很方便。而sqlite2是PHP5默认支持的,很多php虚拟机应该能够支持。现在只是学习,性能不是必须考虑的东西,方便第一!
现准备收集一些php_sqlite的资料。
函数(来自官方文档,直接复制没加修改):
sqlite_array_query — Execute a query against a given database and returns an array
sqlite_busy_timeout — Set busy timeout duration, or disable busy handlers
sqlite_changes — Returns the number of rows that were changed by the most recent SQL statement
sqlite_close — Closes an open SQLite database
sqlite_column — Fetches a column from the current row of a result set
sqlite_create_aggregate — Register an aggregating UDF for use in SQL statements
sqlite_create_function — Registers a "regular" User Defined Function for use in SQL statements
sqlite_current — Fetches the current row from a result set as an array
sqlite_error_string — Returns the textual description of an error code
sqlite_escape_string — Escapes a string for use as a query parameter
sqlite_exec — Executes a result-less query against a given database
sqlite_factory — Opens a SQLite database and returns a SQLiteDatabase object
sqlite_fetch_all — Fetches all rows from a result set as an array of arrays
sqlite_fetch_array — Fetches the next row from a result set as an array
sqlite_fetch_column_types — Return an array of column types from a particular table
sqlite_fetch_object — Fetches the next row from a result set as an object
sqlite_fetch_single — Fetches the first column of a result set as a string
sqlite_fetch_string — Alias of sqlite_fetch_single
sqlite_field_name — Returns the name of a particular field
sqlite_has_more — Finds whether or not more rows are available
sqlite_has_prev — Returns whether or not a previous row is available
sqlite_key — Returns the current row index
sqlite_last_error — Returns the error code of the last error for a database
sqlite_last_insert_rowid — Returns the rowid of the most recently inserted row
sqlite_libencoding — Returns the encoding of the linked SQLite library
sqlite_libversion — Returns the version of the linked SQLite library
sqlite_next — Seek to the next row number
sqlite_num_fields — Returns the number of fields in a result set
sqlite_num_rows — Returns the number of rows in a buffered result set
sqlite_open — Opens a SQLite database and create the database if it does not exist
sqlite_popen — Opens a persistent handle to an SQLite database and create the database if it does not exist
sqlite_prev — Seek to the previous row number of a result set
sqlite_query — Executes a query against a given database and returns a result handle
sqlite_rewind — Seek to the first row number
sqlite_seek — Seek to a particular row number of a buffered result set
sqlite_single_query — Executes a query and returns either an array for one single column or the value of the first row
sqlite_udf_decode_binary — Decode binary data passed as parameters to an UDF
sqlite_udf_encode_binary — Encode binary data before returning it from an UDF
sqlite_unbuffered_query — Execute a query that does not prefetch and buffer all data
sqlite_valid — Returns whether more rows are available
记录于此,准备逐渐翻译学习