search
HomeBackend DevelopmentPHP Tutorial来个高手啊,一个困扰我很久的php问题,求帮助

两个php文件,一个为a.php,代码是

<?phpfunction threadpics($tid,$num=1){	$tableid=substr($tid,-1,1);	$array=array();	$rs=DB::query("SELECT aid FROM  ".DB::table("forum_attachment_{$tableid}")." WHERE  `tid` ='$tid' AND  `isimage` =1 AND `price`=0 order by aid asc LIMIT 0 , $num");	while ($rw=DB::fetch($rs)){		$array[]=$rw;	}	return $array;}?>


另一个b.php,代码是
<?phprequire_once './source/class/class_core.php';$discuz = & discuz_core::instance();$discuz->init();$nopic='./static/image/common/nophotosmall.gif';//ȱʡͼƬ$aid=intval($_G['gp_aid']);if(1){$tableid=DB::result_first("SELECT  `tableid` FROM  ".DB::table("forum_attachment")." WHERE  `aid` ='$aid' LIMIT 0 , 1");$attach=DB::fetch_first("SELECT * FROM  ".DB::table("forum_attachment_$tableid")." WHERE  `aid` ='{$aid}' LIMIT 0 , 1");$thumbfile="./forum/".$attach['attachment'];if(file_exists($thumbfile)){	header("location:{$thumbfile}");	die();}}?>



网页输出图片路径是来个高手啊,一个困扰我很久的php问题,求帮助


求助把b.php文件的代码合并到a.php,网页输出用一个变量来代替,如来个高手啊,一个困扰我很久的php问题,求帮助,请帮忙给个修改后的完整代码,谢谢各位大神了


回复讨论(解决方案)

不明白你的意思!

a.php 只是定义了一个函数,b.php 中并没有调用它

不明白你的意思!

a.php 只是定义了一个函数,b.php 中并没有调用它

网页里的代码来个高手啊,一个困扰我很久的php问题,求帮助,用到了b.php,怎样把来个高手啊,一个困扰我很久的php问题,求帮助里的b.php?aid=$o[aid] 用变量来代替,比如来个高手啊,一个困扰我很久的php问题,求帮助,谢谢

贴全相关代码

贴全相关代码

你好,谢谢你的回复,htm网页的代码是这样的
      
            
来个高手啊,一个困扰我很久的php问题,求帮助
                  

用于discuz列表页获取帖子图片的

贴全相关代码

版主啊,求帮忙

不知道你想表达什么
如果你是想让b.php 这段代码  能在a.php里运行 ,那就加在

while ($rw=DB::fetch($rs)){        $array[]=$rw;    }

这段代码里,定义一个$array[‘tupian’] = (b.php 返回的值)

这样子,return $array 的时候,在html里,解析一下,就可以了

不知道你想表达什么
如果你是想让b.php 这段代码  能在a.php里运行 ,那就加在

while ($rw=DB::fetch($rs)){        $array[]=$rw;    }

这段代码里,定义一个$array[‘tupian’] = (b.php 返回的值)

这样子,return $array 的时候,在html里,解析一下,就可以了

我想表达的是能不能用变量$tupian代替b.php,然后html里解析直接是来个高手啊,一个困扰我很久的php问题,求帮助,而不是来个高手啊,一个困扰我很久的php问题,求帮助。不知道可以吗

不知道你想表达什么
如果你是想让b.php 这段代码  能在a.php里运行 ,那就加在

while ($rw=DB::fetch($rs)){        $array[]=$rw;    }

这段代码里,定义一个$array[‘tupian’] = (b.php 返回的值)

这样子,return $array 的时候,在html里,解析一下,就可以了

还有就是您说的这个代码具体怎么加,请贴一下代码,我php很初级,谢谢

dz好像有个标签,里面写$tupian = b.php?aid=$o[aid];不知道是不是你要问的
提问时最好表达简明准确,你的目的是什么,你碰到的问题是什么

dz好像有个标签,里面写$tupian = b.php?aid=$o[aid];不知道是不是你要问的
提问时最好表达简明准确,你的目的是什么,你碰到的问题是什么


谢了,大概就是你写的这个代码的意思,你的这个代码怎么加啊,
while ($rw=DB::fetch($rs)){
        $array[]=$rw;
 $tupian = b.php?aid=$o[aid];
   }
我这样加直接就报错了


dz好像有个标签,里面写$tupian = b.php?aid=$o[aid];不知道是不是你要问的
提问时最好表达简明准确,你的目的是什么,你碰到的问题是什么


谢了,大概就是你写的这个代码的意思,你的这个代码怎么加啊,
while ($rw=DB::fetch($rs)){
        $array[]=$rw;
 $tupian = b.php?aid=$o[aid];
   }
我这样加直接就报错了


我写的是语法不标准的示例,准确的是
$tupian = 'b.php?aid=' . $rw['aid'];
字符串要加引号
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP Performance Tuning for High Traffic WebsitesPHP Performance Tuning for High Traffic WebsitesMay 14, 2025 am 12:13 AM

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

Dependency Injection in PHP: Code Examples for BeginnersDependency Injection in PHP: Code Examples for BeginnersMay 14, 2025 am 12:08 AM

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

PHP Performance: is it possible to optimize the application?PHP Performance: is it possible to optimize the application?May 14, 2025 am 12:04 AM

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

PHP Performance Optimization: The Ultimate GuidePHP Performance Optimization: The Ultimate GuideMay 14, 2025 am 12:02 AM

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor