MacBook Pro (Retina, 13-inch, Late 2013) 無法登入至桌面

上上個週末,先是前一晚電腦無預警的自動關機,重新開機之後,登入到桌面時雖然有一點久,但還是成功了,當時我單純的以為是我把磁碟容量塞爆的關係,殊不知當天凌晨又再度自動關機,而這一次就再也登入不到桌面啦(崩潰),清晨四點我趕緊查了幾篇文章,測試了下述幾個方法:

  • 重置 NVRAM:開機並立即按住 Option、Command、P 和 R 鍵
  • 重置 SMC
  • 以「安全模式」啓動:開機並立即按住 Shift 鍵
  • 以「單一使用者模式」啓動:開機並立即按住 Command 和 S 鍵
  • 修復磁碟:開機並立即按住 Command 和 R 鍵,使用「磁碟工具程式」修復或清除您的啟動磁碟或其他硬碟
Continue Reading

PHP: copy, move, rename, and delete files

  • copy — Copies file(複製檔案)
  • rename — Renames a file or directory(重新命名或搬移檔案)
  • unlink — Deletes a file(刪除檔案)

copy

  • description:
    bool copy ( string $source , string $dest [, resource $context ] )
  • parameters:
    • source: 來源檔案路徑
    • dest: 目的地路徑
    • context: A valid context resource created with stream_context_create().
  • return values:
    Returns TRUE on success or FALSE on failure.(成功回傳 TRUE,失敗回傳 FALSE)

[php]
<?php
// 檔案複製到 folder 目錄下, 並更名為 example-1.txt
if ( copy("example.txt", "/folder/example-1.txt") )
{
// 複製檔案成功
}
else
{
// 複製檔案失敗
}
?>
[/php]


rename

  • description:
    bool rename ( string $oldname , string $newname [, resource $context ] )
  • parameters:
    • oldname: 原始檔案名稱
    • newname: 新檔案名稱
  • return values:
    Returns TRUE on success or FALSE on failure.(成功回傳 TRUE,失敗回傳 FALSE)

[php]
<?php
// 檔案更名為 newfile.ext
rename("file.ext", "newfile.ext");

// 不同路徑, 移動檔案
rename("file.ext", "/folder/file.ext");

// 不同路徑, 移動檔案並更名
rename("file.ext", "/folder/newfile.ext");
?>
[/php]


unlink

  • description:
    bool unlink ( string $filename [, resource $context ] )
  • parameters:
    • filename: 檔案路徑
  • return values:
    Returns TRUE on success or FALSE on failure.(成功回傳 TRUE,失敗回傳 FALSE)

[php]
<?php
if ( unlink("example.txt") )
{
// 刪除檔案成功
}
else
{
// 刪除檔案失敗
}
?>
[/php]

Continue Reading

PHP: empty(), is_null(), isset() 函數比較表

Comparisons of $x with PHP functions
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 = array(‘a’, ‘b’); array FALSE FALSE TRUE TRUE
$x = false; boolean TRUE FALSE TRUE FALSE
$x = true; boolean FALSE FALSE TRUE TRUE
$x = 1; integer FALSE FALSE TRUE TRUE
$x = 42; integer FALSE FALSE TRUE TRUE
$x = 0; integer TRUE FALSE TRUE FALSE
$x = -1; integer FALSE FALSE TRUE TRUE
$x = “1”; string FALSE FALSE TRUE TRUE
$x = “0”; string TRUE FALSE TRUE FALSE
$x = “-1”; string FALSE FALSE TRUE TRUE
$x = “php”; string FALSE FALSE TRUE TRUE
$x = “true”; string FALSE FALSE TRUE TRUE
$x = “false”; string FALSE FALSE TRUE TRUE

節錄自《PHP type comparison tables》

Continue Reading