Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8814597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:10:03+00:00 2026-06-14T04:10:03+00:00

Update As per the instruction of experts, I’ve modified the code this way: <?php

  • 0

Update
As per the instruction of experts, I’ve modified the code this way:

<?php
//Class Validation
class transaction_validate{
    
private $val_id;
    function __construct($id) {
        $this->val_id = $id;
    }

public function status(){
    //Call our server and decode json value
    $data = $this->get_data($this->val_id);
    $obj = json_decode($data);

    return $obj->status;
}

public function amount(){
    //Call our server and decode json value
    $data = $this->get_data($this->val_id);
    $obj = json_decode($data);

    return $obj->amount;
}


//Create a function for fetching data
private function get_data($sid){
    $url = 'https://domain.com/verify/process.php?trx='.$sid;
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}
}

$validate = new transaction_validate();
$validate->val_id = '5201211120944';
echo $validate->amount();
echo '<br>';
echo $validate->status();

And output is

Warning: Missing argument 1 for transaction_validate::__construct(),

Fatal error: Cannot access private property transaction_validate::$val_id

Confused!

============================Previous Question======================================

I’m just learning OOP style PHP coding. Tried to code a script for personal usage which seems wrong. Code is:

<?php
//Class Validation
class transaction_validate{
    
    var $val_id;
    
    public function status(){
        //Call our server and decore json value
        $data = get_data();
        $obj = json_decode($data);
        
        return $obj->status;
    }
    
    public function amount(){
        //Call our server and decore json value
        $data = get_data();
        $obj = json_decode($data);
        
        return $obj->amount;
    }

    
    //Create a function for featching data
    private function get_data($val_id){
        $url = 'https://domain.com/verify/process.php?trx='.$val_id;
        $ch = curl_init();
        $timeout = 5;
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;
    }
}

$validate = new transaction_validate('5201211120944');
echo $validate->amount();
echo '<br>';
echo $validate->status();

And output is

Fatal error: Call to undefined function get_data() in
/home/userdo/public_html/class.php on line 17

I need to recognize what wrong I did.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:10:05+00:00Added an answer on June 14, 2026 at 4:10 am

    You need to tell PHP the function is in the class context:

    $this->get_data()
    

    As mentioned in comments, you should add a constructor to set the id you are passing in…

    class transaction_validate{
    
        private $val_id;
    
        function __construct($id) {
            $this->val_id = $id;
        }
    
        //...
    

    Also, if you are writing OOP, validation probably belongs on the domain entity that represents a transaction, rather than in a validation helper class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whats the easiest way to enable my page title to update per content div
Do you know which is the safest Queries Per Second rate in update on
Event System handler code: [TcmExtension(My Handler)] public sealed class EventSystem : TcmExtension { public
I'm getting this problem: PHP Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable
UPDATE : The full site code is here - https://github.com/eWizardII/PeerInstruction I have the following
I have a Website something like twitter who are update per 30 seconds or
Check out this code sample of a button and an anchor: http://jsbin.com/ecitex/2/edit I'm trying
per my question Aes Encryption... missing an important piece , I have now learned
My Quick Question is this: Everything seems to be working, except that Trac tickets
I am trying to deploy a simple binary repo in f-droid server as per

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.