Jump to content

PHP visit function!

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
pormadori

pormadori

    Newbie

  • Members
  • PipPip
  • 21 posts
Hi,

I just recently started to learn PHP, but now when I need to create one function I don't know how to.

<html>
<body>
<?php
function visitPage()

?>

</body>
</html>

I just got this far. Sorry.
The idea which I wanted to create is to create a script which goes to page not like redirect but like visits it in background or I know in HTML it is possible to do like this <img src="http://www.page.com/title.html" /> and it will visit the page.
How to create a script in PHP like that? And the reason why I just don't use the example above is because I want to make a parameter that script visits the page 4 time, the next page 1 time.

Edited by pormadori, 05 May 2009 - 08:13 AM.


#2
Guest_Jaan_*

Guest_Jaan_*
  • Guests
Hmm..
Functions work like this:

<?php

function myFunction(){

      // Something here

}

?>

and in html you can't do like this:

<img src="http://www.page.com/title.html" />

you can do like this:

<img src="http://www.page.com/image.jpg" />

or something like that.. or "http://www.page.com/image.php" works also if you are creating an image with PHP

Also if you want to run something 4 times you must use loop functions:

<?php

$i = 1;
while($i<=5){

    // Do something 5 times

}

?>

But I really don't understand what you want :D sorry.. I'm little bit sleepy.. maybe you can explain a little more..

#3
pormadori

pormadori

    Newbie

  • Members
  • PipPip
  • 21 posts
<html>
<body> 
<?php

$i = 1;
while($i<=5){
// Visit page "http://www.page.com/something/title.html" 5 times
}

$i = 1;
while($i<=2){
// After that page is visited 5 times, visit next page "http://www.page.com/somethingelse/title.html" 2 times
}

$i = 1;
while($i<=1){
//After the page above page is visited 2 times, visit next one like 1 time. 
}
?> 

</body>
</html>

In know I've written it in comments. But I explained the idea there. How to make that it work like that? ;D

Edited by pormadori, 05 May 2009 - 06:54 AM.


#4
dzdrazil

dzdrazil

    Newbie

  • Members
  • Pip
  • 5 posts
technically, that code won't work either because you need to increase $i somewhere. your options here are:

$i=1

while($i<=5){

// code

$i = $i + 1;//  or $i++;

}

OR

for($i; $i<=5; $i++)

{

//

}

a for loop is like a while loop, but does 3 things
first, the first thing in between ( )
after it loops through { }, it does the third thing ( )
then, it tests if the second is true. If it is, it loops again { }
then tests the third thing, etc etc

As for what you want to do, you can use the include function if its php or html
include("...")
but there's no "visit" function.

#5
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
I dont believe using the image tag would be proper formatting etc but depending on what you are trying to accomplish yes putting the site in the thing would "visit" the page but you will not get any feedback on it.

include gets the file but its not in a variable form you also may want to try out file_get_contents or as somebody I met in IRC told me they loved curl