www.webdeveloper.com
Results 1 to 2 of 2

Thread: How can I use acces to inside function in classes in PHP5?

  1. #1
    Join Date
    Apr 2012
    Posts
    1

    How can I use acces to inside function in classes in PHP5?

    Hi, i have this code and I need using some like this:

    $set->sql->insert('something text');

    my code:

    class set{


    function sql()

    {

    function insert($gettext) { // INSERT INTO ..... }
    function delete($gettext) { // DELETE ...... }

    }

    $set = new set();

  2. #2
    Join Date
    Apr 2010
    Posts
    227
    Seems like you are well away.

    So you have two php files.

    One is the class file because you should have it seperate.

    The other is the index.php file say.

    in your index.php have.

    PHP Code:


    include("Classes/SetClass.php");
    @
    session_start();

    //if new window then start sessions to store objects

    if (!@$_SESSION['set']){
            
    $_SESSION['set'] = new SetClass();
    }

    //Value of text to be inserted comes from a post say

    if (isset($_POST['submit_insert'])){ 
      
    $_SESSION['set']->insert($_POST['submit_insert']);
    }

    if (isset(
    $_POST['submit_delete'])){ 
      
    $_SESSION['set']->delete($_POST['submit_delete']);


    My post is very basic and shows nothing of the HTML wrapped around the index.php page nor does it show any sanitization etc.
    Last edited by Belrick; 04-23-2012 at 07:15 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles