{"id":14619,"date":"2016-09-13T16:15:12","date_gmt":"2016-09-13T13:15:12","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=14619"},"modified":"2018-01-09T10:28:26","modified_gmt":"2018-01-09T08:28:26","slug":"php-file-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/","title":{"rendered":"PHP File Example"},"content":{"rendered":"<p>In this example we will learn about files and directories, we will also learn how to manipulate them with PHP.\u00a0PHP allows you to work with files and directories stored on the web server.<\/p>\n<p>Files are persistent storage, they are stored on the hard drive and retain there data even after the computer is shut down.\u00a0Directories are used to store files (and even other directories) hierarchically. Files can store different kinds of data.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;8njY7i2QRy6sg8pg&#8217;]<br \/>\n&nbsp;<br \/>\nFor this example we will use:<\/p>\n<ol>\n<li>A computer with PHP&gt;= 5.5 installed<\/li>\n<li>notepad++<\/li>\n<\/ol>\n<h2>1. Checking If Files Exists<\/h2>\n<p>PHP provides some functions that enable you to access useful file information. We can use function <code>file_exists()<\/code> to discover whether a file exists. To get the size of a file we can use <code> filesize()<\/code><\/p>\n<p><span style=\"text-decoration: underline;\"><em>index.php<\/em><\/span><\/p>\n<pre class=\"brush:html; highlight:[24,25]\">  \r\n&lt;!DOCTYPE html&gt; \r\n&lt;html lang=en&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\toverflow:hidden;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n\t \r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt;PHP File Example&lt;\/title&gt;\r\n\t\r\n\t&lt;\/head&gt;\r\n\t&lt;body onload=init()&gt;\r\n&lt;?php\r\nif(file_exists(\"file.html\")){\r\necho filesize(\"file.html\");\r\n\r\n}\r\nelse{\r\n\r\necho \"File Does Not Exist\";\r\n}\r\n\r\n?&gt;\r\n\t&lt;\/body&gt;\r\n\t&lt;\/html&gt;\r\n<\/pre>\n<p>In the above script we check if a particular file exists(line 24), if it exists we echo the file size (line 25)<\/p>\n<h3>1.1 Retrieving File Name From Path<\/h3>\n<p>PHP function<code>basename()<\/code> retrieves a file name from it&#8217;s directory path. The <code>basename()<\/code> will return a file name from a given path, it basically retrieves the last whole string after the rightmost slash.<\/p>\n<pre class=\"brush:bash;\"> \r\n$name=basename(\"\/home\/server\/example\/file.txt\");\r\n<\/pre>\n<p>You can specify a directory name path instead, in which case the rightmost directory name is returned. Here&#8217;s an example that assigns the value <code>example<\/code> to <code>$name<\/code><\/p>\n<pre class=\"brush:bash;\"> \r\n$name=basename(\"\/home\/server\/example\");\r\n<\/pre>\n<p>If we don&#8217;t want the filename extension or suffix, you can strip that off too by supplying the suffix as a second argument to <code> basename() <\/code><\/p>\n<pre class=\"brush:bash;\"> \r\n$name = basename(\"\/home\/server\/example\/file.txt\",\".txt\");\r\n<\/pre>\n<h3>1.2 Time Related Properties<\/h3>\n<p>These properties depend on the operating system in which the files were created and modified. On unix platforms such as Linux, properties include the time that the file was last modified, the time it was accessed and the user permission set on the file.<\/p>\n<ul>\n<li><code>fileatime()<\/code> Returns the time at which the file was last accessed as a unix timestamp.<\/li>\n<li><code>filectime()<\/code> Returns the time at which the file was last as a unix timestamp.<\/li>\n<li><code>filemtime()<\/code> Returns the time at which the file was last modified as a unix timestamp.<\/li>\n<\/ul>\n<h3>1.3 Reading Files<\/h3>\n<p>To read a file from PHP, we need to open it (Some PHP functions allow you to read a file without opening it). After we are through with the file we close it.<br \/>\nWe open a file with<code>fopen()<\/code> and close it with <code>fclose()<\/code><br \/>\n<code>fopen<\/code> takes two parameters the first parameter is the file we want to open and the second parameter is the mode in which we use to open the file.<br \/>\nThe second argument can be one of the following<\/p>\n<ul>\n<li><code>r<\/code> : Opens the file for reading. The file pointer is placed at the beginning.<\/li>\n<li><code>r+<\/code> : Opens the file for reading and writing.<\/li>\n<li><code>w<\/code> : Opens the file for writing only.<\/li>\n<li><code>w+<\/code> : Opens the file for reading and writing, any existing content will be deleted.<\/li>\n<li><code>a<\/code> : Opens the file for appending only. Data is written to the end of an existing file.<\/li>\n<li><code>a+<\/code> : Opens the file for reading and appending. Data is written to the end of an existing file. If the file does not exist, PHP attempts to create it.<\/li>\n<\/ul>\n<p><span style=\"text-decoration: underline;\"><em>file.html<\/em><\/span><\/p>\n<pre class=\"brush:html;\">   \r\n&lt;h2&gt;2 Getting Started&lt;\/h2&gt;\r\nTo demystify cookies in php, we would develop a simple web app that allows users select the font style and font size to display on a website and stores this preference.\r\n&lt;h3&gt;2.1 Working With Cookies&lt;\/h3&gt;\r\nCookies identify a user. Cookies allow web developers store a small amount of data on the user browser(not more than 4kb). Each time a request is sent to the server, the cookies stored on the browser are automatically sent with the request and can be accessed by the server.\r\nCookies are reliable but they are not all that secure because attackers can easily tamper with them, so you should never use cookies alone to authenticate your users or store sensitive data in cookies (e.g passwords). Users can also turn off cookies support in there browsers, so you should be careful when the core functionality of your web app depends on cookies(if your web app depends on cookies to work properly, you should always check if cookies are supported in the browser and if it is not, alert the user about the error)\r\n&lt;h3&gt;2.2 Creating cookies in php&lt;\/h3&gt;\r\nTo create a cookie in php we use the &lt;code&gt;setcookie(name,value,expires,path,domain,secure,httponly)&lt;\/code&gt; method which takes 7 parameters\r\n<\/pre>\n<p>The above document is the file we are about to read. We read and output the file content to the browser.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>index2.php<\/em><\/span><\/p>\n<pre class=\"brush:php; highlight:[24,26,27]\"> \r\n&lt;!DOCTYPE html&gt; \r\n&lt;html lang=en&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\toverflow:hidden;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n\t \r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt;Read File&lt;\/title&gt;\r\n\t\r\n\t&lt;\/head&gt;\r\n\t&lt;body&gt;\r\n&lt;?php\r\n$myfile = fopen( \"file.html\" , \"r\" )\r\nor die ( \"Unable to open file!\" );\r\necho fread($myfile,filesize( \"file.html\" ));\r\nfclose($myfile);\r\n?&gt;\r\n\r\n\r\n\r\n\t&lt;\/body&gt;\r\n\t&lt;\/html&gt;\r\n<\/pre>\n<p>We open the file for reading (line 24). We read its content and close the file(line 26 and 27). The <code>fread() <\/code>function reads from an open file. Its first parameter contains the name of the file to read from, and the second parameter defines the number of bytes to read.<br \/>\nIt&#8217;s considered good programming practice to close all files after you have finished using them. You don&#8217;t want the opened file taking up server resources. To close the file we use PHP <code>fclose()<\/code> function. It takes the name of the file (or a variable that holds the filename) we want to close as a parameter.<\/p>\n<h3>1.4 Using PHP readfile<\/h3>\n<p>PHP <code>readfile()<\/code> function is used to read a file without having to open the file.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>index3.php<\/em><\/span><\/p>\n<pre class=\"brush:php; highlight:[24,25]\"> \r\n&lt;!DOCTYPE html&gt; \r\n&lt;html lang=en&gt;\r\n\t&lt;head&gt;\r\n\t&lt;style&gt;\r\n\thtml, body{\r\n\twidth:100%;\r\n\theight:100%;\r\n\tmargin:0%;\r\n\tfont-family:\"helvetica\",\"verdana\",\"calibri\", \"san serif\";\r\n\toverflow:hidden;\r\n\tpadding:0%;\r\n\tborder:0%;\r\n\t}\r\n\t \r\n\t&lt;\/style&gt;\r\n\t \t\t&lt;meta charset=\"utf-8\" \/&gt;\r\n\t\t&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi\"\/&gt;\r\n\t\r\n\t&lt;title&gt;PHP File Example&lt;\/title&gt;\r\n\t\r\n\t&lt;\/head&gt;\r\n\t&lt;body&gt;\r\n&lt;?php\r\nif(file_exists(\"file.html\")){\r\necho readfile(\"file.html\");\r\n\r\n}\r\nelse{\r\n\r\necho \"File Does Not Exist\";\r\n}\r\n\r\n?&gt;\r\n\t&lt;\/body&gt;\r\n\t&lt;\/html&gt;\r\n<\/pre>\n<h3>1.5 Creating Files<\/h3>\n<p>The <code>fopen() <\/code>function is also used to create a file. If we call fopen() on a file that does not exist, it will create a new file, given that the file is opened for writing (w) or appending (a).<\/p>\n<p><span style=\"text-decoration: underline;\"><em>index4.php<\/em><\/span><\/p>\n<pre class=\"brush:php; highlight:[2,8]\">&lt;?php\r\n$myfile = fopen( \"test.html\" , \"w\" )\r\nor die ( \"Unable to open file!\" );\r\n$txt= \"e-mail(electronic mail) has become an integral part of the internet. Approximately all tech savy people have an email address, if you have a facebook account, you sure registered it with an email address.\r\ne-mails are simply messages that can contain text, attachments and are sent through a computer network to individuals or groups of individuals.\r\nIn this example we are going to learn how to send e-mails with PHP.\r\nFor this example we will use:\";\r\nfwrite($myfile, $txt);\r\nfclose($myfile);\r\n?&gt;\r\n<\/pre>\n<p>In this example we call <code>fopen<\/code> (line 2)on a file that does not exist. This creates a new file. We also write to the file by using PHP <code>fwrite()<\/code>(line 8) function, which takes two parameters, the file we would write to and the text to write.<\/p>\n<h2>2. Summary<\/h2>\n<p>In this example we learnt about files and directories. We also learnt how to open, close, create and write to files with PHP functions.<\/p>\n<h2>3. Download the source code<\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <strong><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/09\/phpfileexample.zip\">phpfileexample<\/a><br \/>\n<\/strong><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example we will learn about files and directories, we will also learn how to manipulate them with PHP.\u00a0PHP allows you to work with files and directories stored on the web server. Files are persistent storage, they are stored on the hard drive and retain there data even after the computer is shut down.\u00a0Directories &hellip;<\/p>\n","protected":false},"author":164,"featured_media":930,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-14619","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PHP File Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"In this example we will learn about files and directories, we will also learn how to manipulate them with PHP.\u00a0PHP allows you to work with files and\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PHP File Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"In this example we will learn about files and directories, we will also learn how to manipulate them with PHP.\u00a0PHP allows you to work with files and\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-09-13T13:15:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-01-09T08:28:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Olayemi Odunayo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Olayemi Odunayo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/\"},\"author\":{\"name\":\"Olayemi Odunayo\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\"},\"headline\":\"PHP File Example\",\"datePublished\":\"2016-09-13T13:15:12+00:00\",\"dateModified\":\"2018-01-09T08:28:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/\"},\"wordCount\":774,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/\",\"name\":\"PHP File Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"datePublished\":\"2016-09-13T13:15:12+00:00\",\"dateModified\":\"2018-01-09T08:28:26+00:00\",\"description\":\"In this example we will learn about files and directories, we will also learn how to manipulate them with PHP.\u00a0PHP allows you to work with files and\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PHP\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/php\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PHP File Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8\",\"name\":\"Olayemi Odunayo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g\",\"caption\":\"Olayemi Odunayo\"},\"description\":\"I am a programmer and web developer, who has experience in developing websites and writing desktop and mobile applications. I have worked with both schematic and schemaless databases. I am also familiar with third party API and working with cloud servers. I do programming on the client side with Java, JavaScript, html, Ajax and CSS while I use PHP for server side programming.\",\"sameAs\":[\"https:\/\/www.webcodegeeks.com\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/olayemi-odunayo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PHP File Example - Web Code Geeks - 2026","description":"In this example we will learn about files and directories, we will also learn how to manipulate them with PHP.\u00a0PHP allows you to work with files and","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/","og_locale":"en_US","og_type":"article","og_title":"PHP File Example - Web Code Geeks - 2026","og_description":"In this example we will learn about files and directories, we will also learn how to manipulate them with PHP.\u00a0PHP allows you to work with files and","og_url":"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2016-09-13T13:15:12+00:00","article_modified_time":"2018-01-09T08:28:26+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","type":"image\/jpeg"}],"author":"Olayemi Odunayo","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Olayemi Odunayo","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/"},"author":{"name":"Olayemi Odunayo","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8"},"headline":"PHP File Example","datePublished":"2016-09-13T13:15:12+00:00","dateModified":"2018-01-09T08:28:26+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/"},"wordCount":774,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","articleSection":["PHP"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/php\/php-file-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/","url":"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/","name":"PHP File Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","datePublished":"2016-09-13T13:15:12+00:00","dateModified":"2018-01-09T08:28:26+00:00","description":"In this example we will learn about files and directories, we will also learn how to manipulate them with PHP.\u00a0PHP allows you to work with files and","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/php\/php-file-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/php-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/php\/php-file-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"PHP","item":"https:\/\/www.webcodegeeks.com\/category\/php\/"},{"@type":"ListItem","position":3,"name":"PHP File Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/417918d9b5811210265e8590509718b8","name":"Olayemi Odunayo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/016b2a353262962fceecf5c274161cd9ef60fdf1593ec95e71d37f5fd9b444f6?s=96&d=mm&r=g","caption":"Olayemi Odunayo"},"description":"I am a programmer and web developer, who has experience in developing websites and writing desktop and mobile applications. I have worked with both schematic and schemaless databases. I am also familiar with third party API and working with cloud servers. I do programming on the client side with Java, JavaScript, html, Ajax and CSS while I use PHP for server side programming.","sameAs":["https:\/\/www.webcodegeeks.com\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/olayemi-odunayo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/14619","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/164"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=14619"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/14619\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/930"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=14619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=14619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=14619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}