1

Lets suppose I have a PHP file file1.php. Something like this:

<?php
class sqlClass {
public function one { //do something }
?>

Then in other PHP file file2.php, I have this:

<?php 
class encryption_class {
public function two { //do something }
}

How can I call the function two which is inside the class encryption_class inside the file2.php from the function one on the file1.php class sqlClass?

1
  • You would have to instantiate the encryption_class within the sqlClass. Or create a static method or use a singleton pattern. Commented Oct 21, 2012 at 13:05

2 Answers 2

2

Like this:

<?php

require_once "file2.php"; 

class sqlClass {
    public function one {
        //do something

        $encript = new encryption_class();
        $encript->two(); 

    }
}
Sign up to request clarification or add additional context in comments.

Comments

1

First include file2 in file1

include_once "file2.php"; 

Then create object and call.

$a = new encryption_class ();
$a->two();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.