In this case, is it necessary to use eval?

class C
{
public static $s = 123;
}

/ / assuming that you now have to access the CRV _ Ranger _ codes through a string of class names, is there any other way to do this than to write this?

$c = "return";
echo eval ("return". $c. ":: $s"); / / 123

< hr >

I would like to add that the real situation is that there is a function

function f ($c) {
/ / it is known that $c is a fully qualified class name, for example, for a class represented by "abcdefC"
/ / and $c, there must be a static variable $s (which may come from an inherited parent class, it doesn"t matter)
/ / the question is, how do I get the value of $s?
/ / it is feasible to use eval. I wonder if there is a better way?
}

Thank you!

Php
Aug.12,2021

<?php

class C
{
public static $s = 123;
}
$x = "s";
$c = new C();
echo $c::$$x;
//123

echo C::$$x;
//123

got it.
you use this

echo get_class_vars("C")["s"];
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bce4e9-30bed.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bce4e9-30bed.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?