PHP中的NULL,”” ,0,”0″,1

$var             =    NULL      ""       0       "0"      1

strlen($var)     =    0         0        1        1       1
is_null($var)    =    TRUE    FALSE    FALSE    FALSE    FALSE
$var == ""       =    TRUE     TRUE     TRUE    FALSE    FALSE
!$var            =    TRUE     TRUE     TRUE     TRUE    FALSE
!is_null($var)   =    FALSE    TRUE     TRUE     TRUE     TRUE
$var != ""       =    FALSE    FALSE    FALSE    TRUE     TRUE
$var             =    FALSE    FALSE    FALSE    FALSE    TRUE

 

OO中self和$this的区别

What is the difference between  $this  and  self ?

Inside a class definition, $this refers to the current object, while  self  refers to the current class.

It is necessary to refer to a class element using  self ,
and refer to an object element using  $this .
Note also how an object variable must be preceded by a keyword in its definition.

The following example illustrates a few cases:

<?php
class Classy {

const       STAT = 'S' ; // no dollar sign for constants (they are always static)
static     $stat = 'Static' ;
public     $publ = 'Public' ;
private    $priv = 'Private' ;
protected  $prot = 'Protected' ;

function __construct( ){  }

public function showMe( ){
    print '<br> self::STAT: '  .  self::STAT ; // refer to a (static) constant like this
    print '<br> self::$stat: ' . self::$stat ; // static variable
    print '<br>$this->stat: '  . $this->stat ; // legal, but not what you might think: empty result
    print '<br>$this->publ: '  . $this->publ ; // refer to an object variable like this
    print '<br>' ;
}
}
$me = new Classy( ) ;
$me->showMe( ) ;

/* Produces this output:
self::STAT: S
self::$stat: Static
$this->stat:
$this->publ: Public
*/
?>

 

open-flash-chart

第三方flash图形库,php,js,asp等可以直接调用

http://teethgrinder.co.uk/open-flash-chart/

 使用中出现过的错误总结:

1.    flash文件路径不对

function open_flash_chart_object( $width, $height, $url, $use_swfobject=true, $base=” ){}

该函数默认flash文件是根目录,如果要引用,必须写到$base中

2.    数据文件路径不对

数据文件注意文件名中的下划线和中划线之分

  //数据文件中可以自定义的参数:

  $this->data_sets = array();

  $this->data = array();
  $this->links = array();
  $this->width = 250;
  $this->height = 200;
  $this->js_path = 'js/';
  $this->swf_path = '';
  $this->x_labels = array();
  $this->y_min = '';
  $this->y_max = '';
  $this->x_min = '';
  $this->x_max = '';
  $this->y_steps = '';
  $this->title = '';
  $this->title_style = '';
  $this->occurence = 0;

  $this->x_offset = '';

  $this->x_tick_size = -1;

  $this->y2_max = '';
  $this->y2_min = '';

  // GRID styles:
  $this->x_axis_colour = '';
  $this->x_axis_3d = '';
  $this->x_grid_colour = '';
  $this->x_axis_steps = 1;
  $this->y_axis_colour = '';
  $this->y_grid_colour = '';
  $this->y2_axis_colour = '';

  // AXIS LABEL styles:         
  $this->x_label_style = '';
  $this->y_label_style = '';
  $this->y_label_style_right = '';

  // AXIS LEGEND styles:
  $this->x_legend = '';
  $this->x_legend_size = 20;
  $this->x_legend_colour = '#000000';

  $this->y_legend = '';
  $this->y_legend_right = '';
  //$this->y_legend_size = 20;
  //$this->y_legend_colour = '#000000';

  $this->lines = array();
  $this->line_default['type'] = 'line';
  $this->line_default['values'] = '3,#87421F';
  $this->js_line_default = 'so.addVariable("line","3,#87421F");';

  $this->bg_colour = '';
  $this->bg_image = '';

  $this->inner_bg_colour = '';
  $this->inner_bg_colour_2 = '';
  $this->inner_bg_angle = '';

  // PIE chart ------------
  $this->pie = '';
  $this->pie_values = '';
  $this->pie_colours = '';
  $this->pie_labels = '';

  $this->tool_tip = '';

  // which data lines are attached to the
  // right Y axis?
  $this->y2_lines = array();

  // Number formatting:
  $this->y_format='';
  $this->num_decimals='';
  $this->is_fixed_num_decimals_forced='';
  $this->is_decimal_separator_comma='';
  $this->is_thousand_separator_disabled='';

  $this->output_type = '';

  //
  // set some default value incase the user forgets
  // to set them, so at least they see *something*
  // even is it is only the axis and some ticks
  //
  $this->set_y_min( 0 );
  $this->set_y_max( 20 );
  $this->set_x_axis_steps( 1 );
  $this->y_label_steps( 5 );

 

漏掉了php_pdo.dll

Unable to load dynamic library ‘C:phpextphp_pdo_mysql.dll

 

PHP Warning: PHP Startup: Unable to load dynamic library ‘C:phpextphp_pdo_mysql.dll’ – 找不到指定的模块。 in Unknown on line 0     错误提示解决办法

配完PHP环境,开启PDO支持MYSQL,结果出现这个错误提示。

只开启了php_pdo_mysql.dll,而把extension=php_pdo.dll给漏掉了,注销掉分号,OK一切正常

一个简单的抓链接spider

首先一个html表单form.html:

<form action="spider.php" method="post">
input your website you’d like to snatch:
<input type="text" name="website">
<input type="submit" value="Submit">
</form>

 

然后是spider.php:

<?php
if ($_POST["website"]) {
    $url = $_POST["website"];
} else {
    $url = ‘http://www.baidu.com’;
}
//echo $url;
$html = file_get_contents($url);
echo "Page : " . $url;
preg_match_all("/http://[^"s’]+/", $html, $matches, PREG_SET_ORDER);
foreach ($matches as $val) {
    echo "<li>|–" . $val[0] . "<br>";
}
?>