{"id":158,"date":"2023-02-18T21:20:19","date_gmt":"2023-02-18T13:20:19","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=158"},"modified":"2023-02-18T21:20:38","modified_gmt":"2023-02-18T13:20:38","slug":"php-convert-string-to-integer","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/18\/php-convert-string-to-integer\/","title":{"rendered":"PHP\u4e2d\u5c06\u5b57\u7b26\u4e32\u8f6c\u5316\u4e3a\u6574\u6570"},"content":{"rendered":"<h4>(int)<\/h4>\n<pre><code class=\"language-php\">&lt;?php\n    $foo = &quot;1&quot;;    \/\/ $foo \u662f\u5b57\u7b26\u4e32\u7c7b\u578b\n    $bar = (int) $foo;    \/\/ $bar \u662f\u6574\u578b\n?&gt;<\/code><\/pre>\n<p><!-- more --><\/p>\n<h4>intval()<\/h4>\n<pre><code class=\"language-php\">&lt;?php\n    $foo = &quot;1&quot;;    \/\/ $foo \u662f\u5b57\u7b26\u4e32\u7c7b\u578b\n    $bar = intval($foo);    \/\/ $bar \u662f\u6574\u578b\n?&gt;<\/code><\/pre>\n<h4>printf()<\/h4>\n<pre><code class=\"language-php\">&lt;?php\n    $foo = &quot;1&quot;;    \/\/ $foo \u662f\u5b57\u7b26\u4e32\u7c7b\u578b\n    $bar = sprintf(&quot;%d&quot;, $foo);    \/\/ $bar \u662f\u5b57\u7b26\u4e32\u7c7b\u578b\n?&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>(int) &lt;?php $foo = &quot;1&quot;; \/\/ $foo \u662f\u5b57\u7b26\u4e32\u7c7b\u578b $ba [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69],"tags":[],"class_list":["post-158","post","type-post","status-publish","format-standard","hentry","category-php-basic"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=158"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/158\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}