This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-05-24 23:54:32

stevetheipad
Scratcher
Registered: 2011-08-06
Posts: 1000+

PHP If help

How can I make an if and else statement that does something if a .txt file equals something?


http://i.imgur.com/0x8ia.jpg
gone

Offline

 

#2 2012-05-25 00:00:27

veggieman001
Scratcher
Registered: 2010-02-20
Posts: 1000+

Re: PHP If help

I don't really know PHP but I think you'd use file() to get the contents of the file and assign that to a string.


Posts: 20000 - Show all posts

Offline

 

#3 2012-05-25 00:38:07

GP1
Scratcher
Registered: 2009-07-06
Posts: 1000+

Re: PHP If help

Code:

<?php
if(file_get_contents("FILEPATH")=="Stuff for it to equal"){
//true
}else{
//file contents do not equal string
}
?>

Last edited by GP1 (2012-05-25 00:38:41)


I am currently http://blocks.scratchr.org/API.php?user=GP1&amp;action=onlineStatus&amp;type=imagehttp://blocks.scratchr.org/API.php?user=GP1&amp;action=onlineStatus&amp;type=text and I finally got over 1000 posts.

Offline

 

#4 2012-05-25 04:52:44

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: PHP If help

Bah, GP1 beat me to it  tongue

It's great you're learning PHP, stevetheipad! A good place to ask questions about it is the coder's shed forums where I go when I have questions about web languages!

If you want to ask about web languages on Scratch, try this thread  smile


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#5 2012-05-25 06:39:06

jji7skyline
Scratcher
Registered: 2010-03-08
Posts: 1000+

Re: PHP If help

Ah yes, I like those forums  smile


I don't know why you say goodbye, I say hello!  big_smile

Offline

 

#6 2012-05-27 03:53:05

slinger
Scratcher
Registered: 2011-06-21
Posts: 1000+

Re: PHP If help

jji7skyline wrote:

Ah yes, I like those forums  smile

Yeah, I'm quite fond of them myself  big_smile


http://s0.bcbits.com/img/buttons/bandcamp_130x27_blue.png

Offline

 

Board footer