Prihlásiť

PHP


PHP UTF-8 cheatsheet

6. 4. 2011 Zobraziť článok

Update your database tables to use UTF-8

CREATE DATABASE db_name
	CHARACTER SET utf8
	DEFAULT CHARACTER SET utf8
	COLLATE utf8_general_ci
	DEFAULT COLLATE utf8_general_ci
	;

ALTER DATABASE db_name
	CHARACTER SET utf8
	DEFAULT CHARACTER SET utf8
	COLLATE utf8_general_ci
	DEFAULT COLLATE utf8_general_ci
	;

ALTER TABLE tbl_name
	DEFAULT CHARACTER SET utf8
	COLLATE utf8_general_ci
	;

Install and configure the mbstring extension for PHP


mbstring.language		= Neutral	; Set default language to Neutral(UTF-8) (default)
mbstring.internal_encoding	= UTF-8		; Set default internal encoding to UTF-8
mbstring.encoding_translation	= On		;  HTTP input encoding translation is enabled
mbstring.http_input		= auto		; Set HTTP input character set dectection to auto
mbstring.http_output		= UTF-8		; Set HTTP output encoding to UTF-8
mbstring.detect_order		= auto		; Set default character encoding detection order to auto
mbstring.substitute_character	= none		; Do not print invalid characters
default_charset			= UTF-8		; Default character set for auto content type header

Deal with non-multibyte-safe functions in PHP

mail()		-> mb_send_mail()
strlen()	-> mb_strlen()	
strpos()	-> mb_strpos()
strrpos()	-> mb_strrpos()
substr()	-> mb_substr()
strtolower()	-> mb_strtolower()
strtoupper()	-> mb_strtoupper()
substr_count()	-> mb_substr_count()
ereg()		-> mb_ereg()
eregi()		-> mb_eregi()
ereg_replace()	-> mb_ereg_replace()
eregi_replace()	-> mb_eregi_replace()	
split()		-> mb_split()

etc. source here: http://developer.loftdigital.com/blog/php-utf-8-cheatsheet


Zobraziť článok

Markdown

7. 2. 2010 Zobraziť článok

PHP Markdown is a port to PHP of the Markdown program written by John Gruber.

Markdownify is a HTML to Markdown converter.


Zobraziť článok

DEFAULT NOW()

6. 7. 2009 Zobraziť článok
Pri datetime v php date("Y-m-d H:i:s") alebo dať ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
Zobraziť článok

Allowed memory size exhausted

18. 3. 2007 Zobraziť článok
  • memory_limit = 12M to your php.ini file (recommended, if you have access)
  • ini_set('memory_limit', '12M');
  • php_value memory_limit 12M in your .htaccess file

Zobraziť článok