{"id":127,"date":"2013-02-06T21:33:05","date_gmt":"2013-02-06T13:33:05","guid":{"rendered":"http:\/\/thephper.com\/?p=127"},"modified":"2013-02-06T21:33:05","modified_gmt":"2013-02-06T13:33:05","slug":"%e5%88%86%e6%9e%90pdf%e6%96%87%e4%bb%b6%e6%80%bb%e9%a1%b5%e6%95%b0fgets%e5%87%bd%e6%95%b0%e6%97%a0%e6%b3%95%e8%af%86%e5%88%ab%e6%8d%a2%e8%a1%8c%e7%ac%a6%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/thephper.com\/?p=127","title":{"rendered":"\u5206\u6790pdf\u6587\u4ef6\u603b\u9875\u6570+fgets()\u51fd\u6570\u65e0\u6cd5\u8bc6\u522b\u6362\u884c\u7b26\u95ee\u9898"},"content":{"rendered":"<p>\u6709\u4e2a\u5c0f\u9700\u6c42\uff0c\u6279\u91cf\u5206\u6790\u4e00\u6279pdf\u6587\u4ef6\u7684\u603b\u9875\u6570\uff0c\u5199\uff08\u627e\uff09\u4e86\u4e2a\u5c0f\u51fd\u6570\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre>\r\n\r\nfunction getPageTotal($path){\r\n    if (!$fp = @fopen($path, 'r')) {\r\n        return false;\r\n    }\r\n    $max=0;\r\n    while(!feof($fp)) {\r\n        $line = fgets($fp,255);\r\n        if (preg_match('\/\\\/Count [0-9]+\/', $line, $matches)){\r\n            preg_match('\/[0-9]+\/',$matches[0], $matches2);\r\n            if ($max<$matches2[0]) $max=$matches2[0];\r\n        }\r\n    }\r\n    fclose($fp);\r\n    return $max;\r\n}\r\n<\/pre>\n<p>\u5b9e\u9645\u4f7f\u7528\u4e2d\uff0c\u53d1\u73b0\u6709\u6781\u4e2a\u522b\u6587\u4ef6\u8bc6\u522b\u5931\u8d25\uff0c\u53d6\u6837\u5206\u6790\u540e\uff0c\u53d1\u73b0\u51fa\u95ee\u9898\u7684\u6587\u4ef6\u90fd\u662fmac\u683c\u5f0f\u7684\uff0c\u90a3\u81ea\u7136\u5c31\u662ffgets\u5bf9mac\u6362\u884c\u7b26\u7684\u8bc6\u522b\u95ee\u9898\u4e86<\/p>\n<p>\u67e5\u4e86\u4e0b\u624b\u518c: <a href=\"http:\/\/www.php.net\/manual\/en\/function.fgets.php\" title=\"fgets\">fgets<\/a><\/p>\n<blockquote><p>\n    Note: If PHP is not properly recognizing the line endings when reading files either on or created by a Macintosh computer, enabling the auto_detect_line_endings run-time configuration option may help resolve the problem.\n<\/p><\/blockquote>\n<p>auto_detect_line_endings \u8fd9\u4e2a\u8fd0\u884c\u65f6\u914d\u7f6e\u5230\u662f\u4ece\u6ca1\u6ce8\u610f\u8fc7\uff0cok\u3001\u7a0d\u4f5c\u4fee\u6539<\/p>\n<pre>\r\n\r\nfunction getPageTotal($path){\r\n    ini_set(\"auto_detect_line_endings\",true);\r\n\r\n    if (!$fp = @fopen($path, 'r')) {\r\n        return false;\r\n    }\r\n    $max=0;\r\n    while(!feof($fp)) {\r\n        $line = fgets($fp,255);\r\n        if (preg_match('\/\\\/Count [0-9]+\/', $line, $matches)){\r\n            preg_match('\/[0-9]+\/',$matches[0], $matches2);\r\n            if ($max<$matches2[0]) $max=$matches2[0];\r\n        }\r\n    }\r\n    fclose($fp);\r\n    return $max;\r\n}\r\n<\/pre>\n<p>\u95ee\u9898\u89e3\u51b3\uff01<\/p>\n<p>\u5173\u4e8e<a href=\"http:\/\/www.php.net\/manual\/en\/filesystem.configuration.php#ini.auto-detect-line-endings\" target=\"_blank\">auto-detect-line-endings<\/a>\u7684\u89e3\u91ca\uff1a<\/p>\n<blockquote>\n<p>    When turned on, PHP will examine the data read by fgets() and file() to see if it is using Unix, MS-Dos or Macintosh line-ending conventions.<\/p>\n<p>    This enables PHP to interoperate with Macintosh systems, but defaults to Off, as there is a very small performance penalty when detecting the EOL conventions for the first line, and also because people using carriage-returns as item separators under Unix systems would experience non-backwards-compatible behaviour.<\/p>\n<p>        Note: This configuration option was introduced in PHP 4.3.0 <\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u6709\u4e2a\u5c0f\u9700\u6c42\uff0c\u6279\u91cf\u5206\u6790\u4e00\u6279pdf\u6587\u4ef6\u7684\u603b\u9875\u6570\uff0c\u5199\uff08\u627e\uff09\u4e86\u4e2a\u5c0f\u51fd\u6570\uff0c\u5982\u4e0b\uff1a func &hellip; <a href=\"https:\/\/thephper.com\/?p=127\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[26,4],"tags":[27,29,28],"_links":{"self":[{"href":"https:\/\/thephper.com\/index.php?rest_route=\/wp\/v2\/posts\/127"}],"collection":[{"href":"https:\/\/thephper.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thephper.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thephper.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thephper.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=127"}],"version-history":[{"count":7,"href":"https:\/\/thephper.com\/index.php?rest_route=\/wp\/v2\/posts\/127\/revisions"}],"predecessor-version":[{"id":134,"href":"https:\/\/thephper.com\/index.php?rest_route=\/wp\/v2\/posts\/127\/revisions\/134"}],"wp:attachment":[{"href":"https:\/\/thephper.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thephper.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thephper.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}