Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2016
    Location
    Cumbria, United Kingdom
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Post Advanced PHP Scripting.

    Hello, I would like to share a great experiment i have been working on for the past 3 weeks. I have been messing around with PHP, HTML, XAMPP
    to create a script that created a file based on what year it is and if the file exists.
    PHP Code:
    <a href="test.php"><button class="button">Winners of <?php echo date("Y"); ?></button></a>
    <!-- PHP SCRIPT TO CREATE YEAR DIRECTORY BASED ON YEAR AND IF FILE DIR EXISTS -->
    <?php
    if (!file_exists(date("Y")))//Checking if year folder exist
    mkdir(date("Y"));//Creating folder if it dosent exist(You may need to add ,0777) in UNI
    clearstatcache(); 
    if(!
    file_exists("index.html")) 

     
    $fp fopen("test.php","w");  
     
    fwrite($fp,"
    <META http-equiv='refresh' content='2;URL=http://192.168.1.226/<?php echo date('Y'); ?>/'>           
      "
    );  
      
    fclose($fp); 

    ?>
    <!-- PHP SCRIPT TO CREATE YEAR DIRECTORY BASED ON YEAR AND IF FILE DIR EXISTS -->
    So far it has been a great success in doing exactly what i wanted it to do. the next thing i plan is to populate the directory with content using just this php code. Now it has been a very stress-full week for me and i have been so frustrated with PHP as i keep running into errors due to php restrictions. If you would like to join me in experimenting let me know.
    Last edited by chump2877; 02-08-2016 at 02:41 PM. Reason: added PHP tags

  2. #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    3,047
    Thanks
    29
    Thanked 169 Times in 160 Posts
    Quote Originally Posted by AlwaysLearing View Post
    Hello, I would like to share a great experiment i have been working on for the past 3 weeks. I have been messing around with PHP, HTML, XAMPP
    to create a script that created a file based on what year it is and if the file exists.
    PHP Code:
    <a href="test.php"><button class="button">Winners of <?php echo date("Y"); ?></button></a>
    <!-- PHP SCRIPT TO CREATE YEAR DIRECTORY BASED ON YEAR AND IF FILE DIR EXISTS -->
    <?php
    if (!file_exists(date("Y")))//Checking if year folder exist
    mkdir(date("Y"));//Creating folder if it dosent exist(You may need to add ,0777) in UNI
    clearstatcache(); 
    if(!
    file_exists("index.html")) 

     
    $fp fopen("test.php","w");  
     
    fwrite($fp,"
    <META http-equiv='refresh' content='2;URL=http://192.168.1.226/<?php echo date('Y'); ?>/'>           
      "
    );  
      
    fclose($fp); 

    ?>
    <!-- PHP SCRIPT TO CREATE YEAR DIRECTORY BASED ON YEAR AND IF FILE DIR EXISTS -->
    So far it has been a great success in doing exactly what i wanted it to do. the next thing i plan is to populate the directory with content using just this php code. Now it has been a very stress-full week for me and i have been so frustrated with PHP as i keep running into errors due to php restrictions. If you would like to join me in experimenting let me know.
    Hello,

    Welcome to CodingForums!

    I respect any person who has the initiative to learn new things.

    Learning anything new for the first time can be frustrating, but I encourage you to stick with it! Knowledge really is power!

    Don't hesitate to post your questions to the forum if you need further help expanding this script. (Though you should probably post those questions to the main PHP forum, as this forum is for completed PHP "snippets" only.)

    Good luck!
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :-)
    [Instructional videos and tutorials are also available on YouTube, Dailymotion, and Vimeo]
    Get free updates about new software version releases, features, and bug fixes!
    ♪♪ …Need Web Hosting For My YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪

  3. Users who have thanked chump2877 for this post:

    AlwaysLearing (02-08-2016)

  4. #3
    New to the CF scene
    Join Date
    Feb 2016
    Location
    Cumbria, United Kingdom
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for welcoming me really appreciate it. I would love to share code with other's on the main thread thanks for the heads up.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •