My php & MySQL FAQ

Source: Internet
Author: User
Tags gpg php mysql solr solr documentation true true
PHP Chinese string length and fixed length interception problem using Str_len ("China") result for 6,php system default one Chinese character length is 3, you can use Mb_strlen function to get length, mb_substr function intercept character

Mb_strlen ($str, "utf-8"); 1 Kanji is 1 characters
Mb_strlen ($str, "gb2312"); The system will think that 1 kanji is 2 characters
Mb_strlen ($STR); If not added, the system will assume that 1 kanji is 3 characters

int Mb_strlen (String str [, string encoding])

String Mb_substr (string str, int start [, int length [, string encoding]]) determines whether the PHP variable is defined, is empty

if ($keyword): If the statement is faulted in the controller without a set-to-page, use the expression isset ($keyword) instead

Expression GetType () empty () Is_null () isset () boolean:if ($x)
$x = ""; String true false True False
$x = null; NULL true True false false
var $x; NULL true True false false
$x is undefined NULL true true false false
$x = Array (); Array true false true False
$x = false; Boolean true false True False
$x = true; Boolean false True True
$x = 1; Integer false False True True
$x = 42; Integer false False True True
$x = 0; Integer true false true false gets the request multivalued parameter

Java-like request.getparametervalues () (actually just know this method, ==! )

Page in form
Background processing request

$kword =$_post[' KWord '];

The CakePHP correspondence method is

$kword = $this->params[' form ' [' KWord '];

When used in the order set $kword[index] index:0-n PHP SOLR Client API takes the Doc field with index not defined error resolution:

SOLR documentation may be incomplete when multiple documents are displayed, if there are no values defined for the field, the index not defined error will occur

Modify the document file for the SOLR client API
Public Function __get ($key) {
Key does not exist return NULL to avoid index not defined error Shen Guanpu July 15, 2010 13:51:52
Return array_key_exists ($key, $this->_fields)? $this->_fields[$key]: "";
return $this->_fields[$key]; Original code} Install CakePHP in a subdirectory Via an Apache Alias
httpd.conf

In httpd.conf, add the following line:alias/directory_name/absolute/path/to/install/directory/app/webroot
. htaccess

In App/webroot/.htaccess, add the following line:rewritebase/directory_name
Your. htaccess file should now appear as such:


Rewriteengine on
Rewritebase/directory_name
Rewritecond% Request_filename!-d
Rewritecond% Request_filename!-f
Rewriterule ^ (. *) $ index.php?url=$1 [qsa,l]

index.php

Finally, in APP/webroot/index.php, on line, right below where it says not to edit below this line, change it to:define (' Webroot_dir ', ' directory_name ');
SOURCE http://www.chriscassell.net/log/2006/07/27/how_to_install_.html MySQL Remote access settings

GRANT all privileges on *. * to root@ "%" identified by ' password ' with GRANT OPTION;

FLUSH privileges; PHP Closed Tags

PHP closed Tag "?>" in PHP for PHP parser is optional. However, if you use a closed tag, any space behind the closed tag by a developer, user, or FTP application may cause extra output, PHP errors, output that cannot be displayed, and blank pages. Therefore, all PHP files should omit this PHP closed tag, and insert a note to indicate that this is the file's bottom and locate the file in the relative path of the application. This will help you to make sure that the document is over and not truncated.

Incorrect:

CORRECT:
/* End of File myfile.php//location:./system/modules/mymodule/myfile.php */php Judging number

BOOL Is_numeric (mixed var) mysql Ignore_space mode
Concat dose not exist error when writing concat function

Change set sql_mode= ' Ignore_space '; Write concat and get the right results.

MySQL Workbench font is too small, the function and "(" between the space actually did not see ... PHP Solr Search Sort

$response = $this->searchsolr->search ($query, $offset, $limit, Array (' sort ' = + ' Wiki-recommend desc, Wiki-score desc ')); Character encoding Conversion

String mb_convert_encoding (String str, string to_encoding [, mixed from_encoding]) CakePHP's XP under Apache configuration

php.ini File Settings Date.timezone = HongKong or the CakePHP home page will appear warning

Apache httpd.conf configuration is primarily set up PHP support and Urlrewrite module startup

LoadModule Php5_module C:/php/php5apache2_2.dll

AddType application/x-httpd-php. php
Phpinidir "c:/php"

#使用cake php To remove comments from the downstream
LoadModule Rewrite_module modules/mod_rewrite.so


DirectoryIndex index.html index.php


# Configure whether the default directory setting allows jumps.
#

Options FollowSymLinks
AllowOverride All
# Order Deny,allow
# Deny from all


# This should is changed to whatever your set DocumentRoot to.
#这个目录的配置同上做更改 Two-dimensional array assignment

$a 1 = Array ("a" and "= 0," b "= 1);
$a 2 = array ("AA" + =, "BB" = 11);
$together = Array ($a 1, $a 2);
foreach ($together as $single) {
$single ["c"] = 3;
}

This will not change any of the assignments and must be done as follows:

foreach ($together as $key = = $value) {
$together [$key] ["c"] = 3;
Use Yum to install and remove PHP
# RPM--import Http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
# Vi/etc/yum.repos.d/utterramblings.repo
[Utterramblings]
Name=jason ' s utter ramblings Repo
baseurl=http://www.jasonlitka.com/media/el$releasever/$basearch/
Enabled=1
Gpgcheck=1
Gpgkey=http://www.jasonlitka.com/media/rpm-gpg-key-jlitka
# Yum Search php
# Yum update php mysql export data
Export table Structure mysqldump--opt-d shorturl-htestdb-utest-ptest> Test.sql
Export Data and table structure mysqldump database name-uroot-p > Xxx.sql
Export Data mysqldump-t database name-uroot-p > Xxx.sql
Export specific table mysqldump-uroot-p-B database name--table table name > Xxx.sql
Mysqldump--opt--single-transaction-d love-ulove-plove> love.sql mysql slave recovery in the event of an unlicensed lock table: fixing MySQL Replicatio n after slaves ' s relay log was corrupted
http://www.redips.net/mysql/replication-slave-relay-log-corrupted/
First show slave status\g; Record two values: Relay_master_log_file Exec_master_log_pos

OK, with this values, new Binlog position can is set:

# Stop Slave

mysql> stop Slave;

# make slave Forget it replication position in the master ' s binary log

mysql> Reset Slave;

# change Slave to start reading from stopped position

mysql> Change Master to master_log_file= ' mysql-bin.002045 ', master_log_pos=103641119;

# start Slave

mysql> start slave;

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.