2012年5月17日 星期四

Programming Working Journal

Check-in: Tired, but fine.

Actually:
20:40-23:26 (-20 min nap) Great! Make some major progress with term you didn't know before : )
Schedule:
20:40-23:40 (3h) Google unknown term/method of the log in system, rewrite it.
Trim; md5; function, false-true variable

Reading https://github.com/simfatic/RegistrationForm/blob/master/source/include/fg_membersite.php

Need to understand the following, get a quick google search, and practice to use it to write code:
- define
 http://www.w3school.com.cn/php/func_misc_define.aspdefine("Aaaa", "Hello world")
echo "Aaaa";
-> appear Hello world
- array_push
-> add multiple things to the end of array
array_push($a, "tik", "nik");
-> $a([5]->tik, [6]->nik)
print_r($a)-> return everything of the $a array!
- print
To be exploredhttp://php.net/manual/en/function.print.php
- $bret?sometimes refer as $bRetMight be the same thing as boolean return ($breturn)
- $this->sitenamehttp://stackoverflow.com/questions/1523479/what-does-the-variable-this-mean-in-php"The pseudo-variable $this is available when a method is called from within an object context." from php.net
It is used under an object oriented environment.I guess my question was, why do we need $this.
Then, it make sense to use it as the following show: 
function a($x){ return $this->error_hash;}
As the function can be later been called within a class.
related: difference between self and $this http://stackoverflow.com/questions/151969/php-self-vs-this
more on object oriented programming:
http://www.phpfreaks.com/tutorial/oo-php-part-1-oop-in-full-effecthttp://www.phpfreaks.com/tutorial/oo-php-part-1-oop-in-full-effect
Otherhttp://en.wikipedia.org/wiki/Php#Release_historyhttp://us3.php.net/manual/en/language.oop5.basic.php

- !isset
isset is use to see whether a variable has been set
-> if it is "unset" or equal to "null" it will return with false
http://php.net/manual/en/function.isset.php
- empty
http://php.net/manual/en/function.empty.php
empty= isset+ "" + $a=0 +false
http://php.net/manual/en/function.empty.php

-----------------------------2012.5.19 --------------------------------------------------------------

- substr(md5(uniqid()),0,10)
-> substr is a difficult one.


- if(!result|| mysql_num_rows($rows)<=0)
-> mysql_num_rows() and mysq_affected_rows()
the former for counting the number we have last SHOW or SELECT;
and the later includes number for INSERT, DELETE and other.
http://php.net/manual/en/function.mysql-num-rows.phphttp://www.php.net/manual/en/function.mysql-affected-rows.php

- return true/falsePracticing.
- explodehttp://php.net/manual/en/function.explode.phpcut down string into array of substring.
explode(" ", $sting)
<?
$strin="This is a wonderfull day ";
$strin2= array(3, 4, 5, 6, 9);
$strin3=315634223233233;
$strin4="Taiwan (i/?ta??w??n/ ty-wahn; Chinese: 臺灣 or 台灣; pinyin: Taiw?n; see below), officially the Republic of China (ROC; Chinese: 中華民國; pinyin: Zh?nghua Minguo), is a state in East Asia. Originally based in mainland China, the Republic of China now governs the island of Taiwan (formerly known as Formosa), which forms over 99% of its current territory,[f] as well as Penghu, Kinmen, Matsu, and other minor islands. Neighboring states include the People's Republic of China to the west, Japan to the east and northeast, and the Philippines to the south. Taipei is the capital city and economic and cultural centre of the country,[1] and New Taipei is the most populous city.";
$tran_space=explode(" ",$strin);
print_r($tran_space);
echo "</br></br></br>";
//$tran _null=explode("",$strin);
//print_r($tran_space);
//echo "</br></br></br>";
$tran_array=explode(",", $strin2);
print_r($tran_array);
echo "</br></br></br>";
$tran_3=explode("3", $strin3);
print_r($tran_3);
echo "</br></br></br>";
$tran4=explode("Taiwan", $strin4);
print_r($tran4);
echo "</br></br></br>";
$tran5=explode(".", $strin4);
print_r($tran5);
?> 

- strlen()
http://php.net/manual/en/function.strlen.phplength of string;
"Null"=0
"-2"= 2
"Hello world"=12
- Difference between 'apostrophe' and "Quotation"
->Can use variable ($a->7) in the Quotation, while within apostrophe, variable remains the same($a->$a)
http://bytes.com/topic/php/answers/750143-difference-between-quotation-apostrophe-php
 - preg_match
search for a regular expression http://php.net/manual/en/function.preg-match.phpI am still not familiar with regular expression; this will help me to write filter; and e-mail related function.related: in_array() search an array for a specific value.
-is_numerichttp://php.net/manual/en/function.is-numeric.php

-require_once("class,phpmailer.php");




There is something interesting about this expression, study it more: 


<?php
$tests 
= array(
    
"42",
    
1337,
    
"1e4",
    
"not numeric",
    array(),
    
9.1);

foreach (
$tests as $element) {
    if (
is_numeric($element)) {
        echo 
"'{$element}' is numeric"PHP_EOL;
    } else {
        echo 
"'{$element}' is NOT numeric"PHP_EOL;
    }
}
?>






沒有留言:

張貼留言