Learning PHP

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
Well, I'm 5 weeks before in PHP class, and my teacher don't know what I should do, neither do I.

Can anyone give me something to do that will take around 60 - 80 minutes?
 

jrobert755

New Member
Messages
15
Reaction score
0
Points
0
do you mean behind? if so, try tizag.com
its a great html, java, php, and php/mysql tutorial website
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
do you mean behind? if so, try tizag.com
its a great html, java, php, and php/mysql tutorial website

No I am before everyone else. My teacher didn't expect someone to already know PHP, so he did no extra things for me.

I am like a secondary teacher, and that isn't fun, because they are asking to easy questions.

Like a guy didn't know how to use echo, *facepalm*
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
Hey vigge, haven't seen you in a while... *cough* long while *cough*
If you don't say what you already know in php it's quite hard for anyone to give you an idea of something to do. Just think of something you might be able to make (or maybe it's more fun if you think you won't be able to make it) and make it.
If you need a function, don't know how to do something or things like that there's a very useful site www.php.net ;)
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
Hey vigge, haven't seen you in a while... *cough* long while *cough*
If you don't say what you already know in php it's quite hard for anyone to give you an idea of something to do. Just think of something you might be able to make (or maybe it's more fun if you think you won't be able to make it) and make it.
If you need a function, don't know how to do something or things like that there's a very useful site www.php.net ;)

Long time, no see :D

I know for loops, while loops, if cases, switch, functions, math, basic SQL (insert, select, order), Own sorting algorithm.

So all basic, you know.

My teacher gave me to solve the fibonacci numbers and primes up to 100, which I both did in 1 lesson.
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
build your own software in the time that others are learning it :p. your teacher can grade you on that, depending on how much they actually know about it.

talk it over or see what college level classes are teaching ;)
 

marshian

New Member
Messages
526
Reaction score
9
Points
0
Long time, no see :D

I know for loops, while loops, if cases, switch, functions, math, basic SQL (insert, select, order), Own sorting algorithm.

So all basic, you know.

My teacher gave me to solve the fibonacci numbers and primes up to 100, which I both did in 1 lesson.

Fibonacci is too easy =/
Prime numbers are more of a challenge, because there's no way to determine whether a number is a prime number based on the previous number... The only way I can see to do that is brute force...

But... numbers are boring, it's always the same ^^
It's much more interesting to build something that is dependant on user input. If your scripts don't have a time limit you could dive into plain sockets and let 2 scripts communicate with each other (one acting as a server, one acting as a client). It gets even more fun when you combine 2 languages like that, but I doubt your php teacher will like that :biggrin:

I've got something a friend told me once that you can make. You know that total bs where they determine the love % between two people? It's not a random number...
This is how it works, based on an example:
Name 1: imnotanoob
Name 2: yesyouare
You count the amount of times each letter is in the names:
#a: 2
#b: 1
#e: 2
#i: 1
#m: 1
#n: 2
#o: 4
#r: 1
#s: 1
#t: 1
#u: 1
#y: 2
In Array-form: (2, 1, 2, 1, 1, 2, 4, 1, 1, 1, 1, 2)
Then you take the first and the last letter (of the letters which are available) and you add that to a new array. (If the number of available letters is odd, you just leave the middle one (eg. (1, 1, 1) => (2, 1))
The example becomes then: (4, 2, 3, 2, 2, 6)
Just repeat that, and when the number exceeds 9, you take the ciphers and count them together to get a new number (eg. 12 => 1+2 = 3)
(10, 4, 5) => (1, 4, 5)
Eventually you only have 2 numbers left, that's the actual result:
(6, 4)
(Guess how many times you get something with an 0 in it? 0 times ;))
So the love % between imnotanoob and yesyouare would be 64%.

Have fun programming ;)

Or you could just try to recreate my signature =P
 

JKoltner

New Member
Messages
23
Reaction score
0
Points
0
Fibonacci is too easy =/
Prime numbers are more of a challenge, because there's no way to determine whether a number is a prime number based on the previous number... The only way I can see to do that is brute force...

There are actually some very clever methods to somewhat reduce the time needed to determine whether or not a number is prime, although understanding how some of them actually work requires an upper-class college or graduate level mathematics background.

But... numbers are boring, it's always the same ^^

I agree, if you're just trying to learn PHP, writing math programs is probably more depressing than useful.

It's much more interesting to build something that is dependant on user input.

Yep, also agree.

If your scripts don't have a time limit you could dive into plain sockets and let 2 scripts communicate with each other (one acting as a server, one acting as a client). It gets even more fun when you combine 2 languages like that, but I doubt your php teacher will like that :biggrin:

If his teacher is any good he'll be most impressed and encourage him.

---Joel
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
Prime numbers are more of a challenge, because there's no way to determine whether a number is a prime number based on the previous number... The only way I can see to do that is brute force...


PHP:
function isPrime($i)
      {
         if($i % 2 != 1) return false;
          $d = 3;
          $x = sqrt($i);
          while ($i % $d != 0 && $d < $x) $d += 2;
          return (($i % $d == 0 && $i != $d) * 1) == 0 ? true : false;
       }
for($i = 0; $i <= 100; $i++){
    $No[$i] = $i;
    
        if(isPrime($No[$i])) {
        echo "$i<br />";
        
    } 
}
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
:/

My teacher didn't accept that solution. I hope he accepts this, which I wrote all by myself:

PHP:
for($i = 0; $i <= 100; $i++){
    $No[$i] = $i;
    $True = true;
    $True2 = true;
    
    if(is_int($No[$i]/2)) {
        $True = false;
        $No[$i] = -1;
    }
    
    if($True) {
        if(is_int($No[$i]/3)) {
            $True2 = false;
            $No[$i] = -1;
        }
    }
    
    if($True2) {
        if(is_int($No[$i]/5)) {
            $No[$i] = -1;
        }
    }
     if($No[$i] == 1) {
        $No[$i] = -1;
    }
    
    $No[2] = 2;
    $No[3] = 3;
    $No[5] = 5;
    $No[49] = -1;
    $No[77] = -1;
    $No[91] = -1;
    
    if($No[$i] > 0) {
        echo $No[$i]."<br />";
    }
    

}
 

Parsa44

New Member
Messages
232
Reaction score
0
Points
0
I would suggest doing one of those "dynamic" images, or PHP that retreives data, e.g tells you the weather ect..

Something interactive and impressive to get your rep up infront of the rest of the class.
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
Actually, I made a misstake on that php. here is the proper I did:

PHP:
<?php
for($i = 0; $i <= 100; $i++){
    $No[$i] = $i;
    $True = true;
	$True2 = true;
	
    if(is_int($No[$i]/2)) {
		$True = false;
		if($No[$i]>2){
			echo "<font style=\"text-decoration:line-through; color:#ff0000\">". $No[$i]."</font><br />";
		$No[$i] = -1;
		}
	}
	
	if($True) {
		if(is_int($No[$i]/3)) {
			$True = false;
			if($No[$i] >3){
				echo "<font style=\"text-decoration:line-through; color:#ff0000\">". $No[$i]."</font><br />";
			$No[$i] = -1;
			}
		}
	}
	
	if($True) {
		if(is_int($No[$i]/5)) {
			$True = false;
			
			if($No[$i] >5) {
				echo "<font style=\"text-decoration:line-through; color:#ff0000\">". $No[$i]."</font><br />";
			$No[$i] = -1;
			}
		}
	}
	
	if($True) {
		if(is_int($No[$i]/7)) {
			if($No[$i] >7) {
				echo "<font style=\"text-decoration:line-through; color:#ff0000\">". $No[$i]."</font><br />";
			$No[$i] = -1;
			}
		}
	}
	
	 if($No[$i] == 1) {
		$No[$i] = -1;
	}
	
	
	if($No[$i] > 0) {
		echo "<font style=\"text-decoration:underline; color:#00ff00\">". $No[$i]."</font><br />";
	}
	

}
?>
 
Top