ラベル PHP の投稿を表示しています。 すべての投稿を表示
ラベル PHP の投稿を表示しています。 すべての投稿を表示

2014/12/19

php study memo

Each active resource has a unique identifier. Each identifier is a numerical index into
an internal PHP lookup table that holds information about all the active resources. PHP
maintains information about each resource in this table, including the number of references
to (or uses of) the resource throughout the code. When the last reference to a
resource value goes away, the extension that created the resource is called to free any
memory, close any connection

=->
$res=database_connect();
...
$res="boo"

automatic cleanup

// is_resource()
==>Many modules provide several functions for dealing with the outside world

if(is_resource($..)){
   
}

is_null($x)


★static variables
function updateCounter(){
     static  $counter=0;
     $counter ++;
     echo "Static function variables is now {$counter}\n";
}



★copy on write----------
必要な時だけ、メモリーを使う

Symbol
Each value pointed to by a symbol table has a reference count, a number that represents
the number of ways there are to get to that piece of memory. After the initial assignment
of the array to $worker and $worker to $other, the array pointed to by the symbol table
entries for $worker and $other has a reference count of 2.1 In other words, that memory
can be reached two ways: through $worker or $other. But after $worker[1] is changed,
PHP creates a new array for $worker, and the reference count of each of the arrays is
only 1.


★function parameter----------------------
func_num_args ==>$#?
func_get_args=>
func_get_arg(1)=>$1

isset(a)
isset(b)
==>設定されている?


Single-quoted strings do not interpolate variables.
echo '$name'
==>$name


$a= array(,,)
print_r($a)

Beware of using print_r() or var_dump() on a recursive structure such as $GLOBALS
(which has an entry for GLOBALS that points back to itself). The print_r() function loops
infinitely, while var_dump() cuts off after visiting the same element three times.

var_dump(true)
==>bool(true)


★echo $_COOKIE['PHPSESSID'];
==>これはないと、何もかわらない。。
session_start() ;

Build-in PHP Data Objects
==>PDO
The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for
accessing databases in PHP. Each database driver that implements the PDO interface can
expose database-specific features as regular extension functions. Note that you cannot
perform any database functions using the PDO extension by itself; you must use a database-
specific PDO driver to access a database server.


file_exists($folder)
mkdir
folder
fread
fclose


imagecreate(width,heigth)
imagecolorallocate(image,red,green,blue)
imagegif
imagejpeg

2014/06/06

php window install

・apache install
Apacheをダウンロードするために「Apache Lounge」にアクセスします。???
http://www.apachelounge.com/

==>apache2.4

・php for windows download
http://windows.php.net/download/

64!!


「php5ts.dll 」ファイルをC:\WINDOWSディレクトリ内のsystem32ディレクトリにコピーします (Wind9×/MEではsystemディレクトリ)。

次に、「 php.ini-development 」ファイルをWINDOWSディレクトリにコピーした上でphp.ini-developmentファイルの名前を 「 php.ini 」に変更します。
==ー>れはね、http.confで「PHPIniDir: "C:/php5"」で指定できる。
あそこはデフォルト値よ。。

・httpd.conf の設定php
LoadModuleの項に次の行を追加します。 これでApache2にPHPモジュールを適用します。

LoadModule php5_module c:/php/php5apache2_2.dll

AddTypeの項の最後に次の行を追加し、Apache2にphpのファイル形式を定義します:

AddType application/x-httpd-php .php

==>
PHPで使う拡張子(.php)とPHPを関連付けます。例えば"sample.php"というファイルへアクセスがあった場合に、ファイルの内容をそのまま返すのではなく、ファイルに書かれたスクリプトをPHPで実行しその結果を返すようになります。


・php.ini の設定
doc_root==->apahceのhtdocs
ext->phpのext


・環境変数を追加する
pathにphpのインストール


・テスト:
<?php
phpinfo();
?>


・mysql接続設定
php.ini!!

; On windows:
extension_dir = "ext"
extension=php_mysql.dll
extension=php_pdo_mysql.dll