/    Sign up×
Community /Pin to ProfileBookmark

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();

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@BelrickApr 24.2012 — 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.

[code=php]


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']);
}



[/code]



My post is very basic and shows nothing of the HTML wrapped around the index.php page nor does it show any sanitization etc.
×

Success!

Help @postaczech spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...