Coding Academy

Comments, suggestions and questions about Linux Format magazine and the coverdiscs

Moderators: ChrisThornett, LXF moderators

Coding Academy

Postby freelinuxusa » Thu Aug 26, 2010 7:47 pm

I recently purchased LXF135, which contained a booklet called Paul Hudson's PHP Coding Academy. The booklet provided installation instructions, which I found confusing and therefore, I am asking for help.
I would like to get familiar with coding and want to complete the things mentioned in the booklet. However it mentions loading php5-mysql, Apache using "Mark for instillation", which seems straight forward. However, it later mentions installing php5.cll and php5.gd manually. Aren't they part of php5? How do you load them manually?

Respectfully,
Vincent
freelinuxusa
 
Posts: 1
Joined: Thu Aug 26, 2010 7:35 pm

Postby EvilD@ve » Wed Oct 06, 2010 12:03 am

I also have LXF 135 with Paul Hudson's PHP Coding Academy booklet, and the part your having trouble with just means to enter "php5.cli" and "php5.gd" into the search box the way you did with "php5-mysql" , and "Apache"

My problem with Paul's PHP Coding Academy is on page 22 when I entered in the code for the loop to list all the dir and the subdir I recieved a syntac error on line 7. Now you'd think I typed something in incorrectly, but after several failed attempts to find my typo I shut the computer off for the night and went to bed when I got up the next day to try again I loaded the program and ran it again it ran with no error messages but didn't create any output either. So after messing with that for awhile with no success, I went to the next step in the booklet and successfully created the output file but it to was empty.

Can we say HUH?????

Now we all know I've type something in wrong but for the life of me, I can't find it. So I'm using copy and paste to put my code in here if you see my misstake I'd really be grateful.

Code: Select all
<?php

function subdir_scan($dir){
   $files=scandir($dir);
   foreach($files as $file){
      if($file == ".") continue;
      if($file == "..") continue;
         
      print "$dir/$file\n";

      if(is_dir("$dir/$file")){
         subdir_scan("$dir/$file");
      }
   }
}

?>



I'll check back if anyone wishes to exchange idea's

Note: Edited by ollie to put "code" tags around the PHP snippet.
EvilD@ve
 
Posts: 2
Joined: Tue Oct 05, 2010 10:39 pm
Location: Rockford IL USA

Postby bobthebob1234 » Wed Oct 06, 2010 7:44 am

you've made a function that (to me) looks ok, however you don't run /call that function. So you've told it how to subdir_scan, but you never ask it to subdir_scan!
For certain you have to be lost to find the places that can't be found. Elseways, everyone would know where it was
User avatar
bobthebob1234
LXF regular
 
Posts: 1372
Joined: Thu Jan 03, 2008 9:38 pm
Location: A hole in a field

Postby Ram » Thu Oct 07, 2010 10:52 pm

Page 23

"Once we've defined our own custom function, we can use it like any other PHP function. So, put this at the bottom of project1.php:"

subdir_scan(".");

Code: Select all
<?php

function subdir_scan($dir){
   $files=scandir($dir);
   foreach($files as $file){
      if($file == ".") continue;
      if($file == "..") continue;
         
      print "$dir/$file\n";

      if(is_dir("$dir/$file")){
         subdir_scan("$dir/$file");
      }
   }
}

subdir_scan(".");

?>

lubuntu LXDE 13.10 running on AMD Phenom II*4; ASUS Crosshair III Formula MB; 4 GB Ram.....
User avatar
Ram
LXF regular
 
Posts: 1676
Joined: Thu Apr 07, 2005 9:44 pm
Location: Guisborough

Postby bobthebob1234 » Fri Oct 08, 2010 11:30 am

so I was right. Yay.
For certain you have to be lost to find the places that can't be found. Elseways, everyone would know where it was
User avatar
bobthebob1234
LXF regular
 
Posts: 1372
Joined: Thu Jan 03, 2008 9:38 pm
Location: A hole in a field

Postby EvilD@ve » Mon Oct 11, 2010 1:45 am

I just want to thank everyone for their response I missed that part in the book when I went back and read it again I notice my mistake thanks to everyone pointing it out.
EvilD@ve
 
Posts: 2
Joined: Tue Oct 05, 2010 10:39 pm
Location: Rockford IL USA


Return to Magazine and coverdiscs

Who is online

Users browsing this forum: No registered users and 3 guests