من می خواهم در بیرون تابع به متعییر $yدسترسی داشته باشم چگونه میشه؟
```
public function read_url_file_li()
{
$file۱=file_get_contents('li.txt');
preg_match_all("/https:\/\/www.aparat.com\/v\/[۰-۹a-z]{۱,۵}/im",$file۱,$li);
foreach ($li[۰] as $li۱) {
$ch۲۲ = curl_init();
curl_setopt($ch۲۲, CURLOPT_URL, $li۱);
curl_setopt($ch۲۲, CURLOPT_FOLLOWLOCATION, ۱);
curl_setopt($ch۲۲, CURLOPT_RETURNTRANSFER, ۱);
curl_setopt($ch۲۲, CURLOPT_ENCODING, "");
$url۲ = curl_exec($ch۲۲);
curl_close($ch۲۲);
echo $url۲;
preg_match_all("/<h۱ class=\"vone__title\">[\W\w]*?<\/h۱>/im", $url۲,$f);//تایتل یا اسم کلیب
$y= implode($f[۰]);
echo $y;
]);
}
}
باید یک class بسازید و به این صورت عمل کنید:
<?php
class test {
public $y ;
public function read_url_file_li()
{
$file۱=file_get_contents('li.txt');
preg_match_all("/https:\/\/www.aparat.com\/v\/[۰-۹a-z]{۱,۵}/im",$file۱,$li);
foreach ($li[۰] as $li۱) {
$ch۲۲ = curl_init();
curl_setopt($ch۲۲, CURLOPT_URL, $li۱);
curl_setopt($ch۲۲, CURLOPT_FOLLOWLOCATION, ۱);
curl_setopt($ch۲۲, CURLOPT_RETURNTRANSFER, ۱);
curl_setopt($ch۲۲, CURLOPT_ENCODING, "");
$url۲ = curl_exec($ch۲۲);
curl_close($ch۲۲);
echo $url۲;
preg_match_all("/<h۱ class=\"vone__title\">[\W\w]*?<\/h۱>/im", $url۲,$f);//تایتل یا اسم کلیب
$y= implode($f[۰]);
$this->y = $y ;
echo $y;
]);
}
}
public function getY(){
$y = $this->y ;
}
}
?>
در ضمن کد های خودتون رو در ادیتور کد قرار بدین تا منظم تر نمایش داده بشه و بهتر بشه کمکتون کرد.
باید یک class بسازید و به این صورت عمل کنید:
<?php
class test {
public $y ;
public function read_url_file_li()
{
$file۱=file_get_contents('li.txt');
preg_match_all("/https:\/\/www.aparat.com\/v\/[۰-۹a-z]{۱,۵}/im",$file۱,$li);
foreach ($li[۰] as $li۱) {
$ch۲۲ = curl_init();
curl_setopt($ch۲۲, CURLOPT_URL, $li۱);
curl_setopt($ch۲۲, CURLOPT_FOLLOWLOCATION, ۱);
curl_setopt($ch۲۲, CURLOPT_RETURNTRANSFER, ۱);
curl_setopt($ch۲۲, CURLOPT_ENCODING, "");
$url۲ = curl_exec($ch۲۲);
curl_close($ch۲۲);
echo $url۲;
preg_match_all("/<h۱ class=\"vone__title\">[\W\w]*?<\/h۱>/im", $url۲,$f);//تایتل یا اسم کلیب
$y= implode($f[۰]);
$this->y = $y ;
echo $y;
]);
}
}
public function getY(){
$y = $this->y ;
}
}
?>
در ضمن کد های خودتون رو در ادیتور کد قرار بدین تا منظم تر نمایش داده بشه و بهتر بشه کمکتون کرد.
2024 © Copyright کليه حقوق مادی و معنوی براي چسبون محفوظ است و هرگونه کپی برداری پیگرد قانونی دارد.