Jump to content

call another function in main page..


nrsh_ram

Recommended Posts

hello to all,

im new to php..

i need help...i learn a simple thing through php tutorials in net..

 

i have create a features_hod.php where have 4 tabs "profile,forms,report,search"...each tab have different functions:

 

eg:'profile->update,preview'  'forms->consultation,discussion,activity,attendance  'report->all,differ,active,withdraw,graduate'  'search->directly open the search form'

 

for example when i click the profile tab..it will show two function 'update n preview', for calling this functions...im using this coding

 

<?php

if (isset($_GET['pg']) && $_GET['pg'] != "") {

$pg = $_GET['pg'];

if (file_exists(''.$pg.'.php')) {

@include (''.$pg.'.php');

 

} elseif (!file_exists(''.$pg.'.php')) {

echo 'Page you are requesting doesn´t exist';

}

 

} else {

@include ('main/Features_HOD.php');

}

?>

 

by using this coding each tab can call own function, my problem is..how to i call the pages of this functions? i want if i click on 'update' it will show the update page, and wen i click on 'preview' it will show preview page...what is the coding? i really no idea...plz help

 

Link to comment
Share on other sites

I'm not sure I follow your question. As you showed in your code, you can include another file's code with the include() function.

 

Are you asking how to call a function within that included file? If so, you call a function in exactly the same way as you normally would. When you include a file, it is exactly as if the code in that included file was present in the file doing the including. I.e. The following combination of foo.php and bar.php is identical to foobar.php:

 

foo.php:

<?php
include("bar.php");
bar();
?>

 

bar.php:

<?php
function bar(){
    echo 'foobar';
}
?>

 

foobar.php

<php
function bar(){
    echo 'foobar';
}
bar();
?>

 

If that wasn't what you were asking, then please rephrase your question.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.