Page 1 of 1

sub routines in php

Posted: Mon Jan 16, 2006 5:29 pm
by dangre
Greetings board members!

I'm new to php and this message board, and do some programming in asp. In asp you can call a sub-routine during some user event. For example:

<%
Sub UserDoesSomething
response.redirect "mypage.asp"
End Sub
%>

<%
If x = 1 Then
Call UserDoesSomething
Else
End If
%>


I was wondering what the php equivalent is to writing and calling a sub like the example above?

Thanks much for the post backs!

Posted: Mon Jan 16, 2006 5:41 pm
by Jenk
functions :)

Code: Select all

<?php
function UserDoesSomething ()
{
    header('Location: http://www.mydomain.com/mypage.php');
}

if ($x == 1) {
    UserDoesSomething();
}
?>

Posted: Mon Jan 16, 2006 6:40 pm
by dangre
Fantastic, just what I was looking for. Thanks a million! :D