两个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();}}?>
网页输出图片路径是

求助把b.php文件的代码合并到a.php,网页输出用一个变量来代替,如

回复讨论(解决方案)
不明白你的意思!
a.php 只是定义了一个函数,b.php 中并没有调用它
不明白你的意思!
a.php 只是定义了一个函数,b.php 中并没有调用它



贴全相关代码
贴全相关代码
你好,谢谢你的回复,htm网页的代码是这样的
用于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里解析直接是


不知道你想表达什么
如果你是想让b.php 这段代码 能在a.php里运行 ,那就加在
while ($rw=DB::fetch($rs)){ $array[]=$rw; }
这段代码里,定义一个$array[‘tupian’] = (b.php 返回的值)
这样子,return $array 的时候,在html里,解析一下,就可以了 还有就是您说的这个代码具体怎么加,请贴一下代码,我php很初级,谢谢
dz好像有个
提问时最好表达简明准确,你的目的是什么,你碰到的问题是什么
dz好像有个
提问时最好表达简明准确,你的目的是什么,你碰到的问题是什么
谢了,大概就是你写的这个代码的意思,你的这个代码怎么加啊,
while ($rw=DB::fetch($rs)){
$array[]=$rw;
$tupian = b.php?aid=$o[aid];
}
我这样加直接就报错了
dz好像有个
提问时最好表达简明准确,你的目的是什么,你碰到的问题是什么
谢了,大概就是你写的这个代码的意思,你的这个代码怎么加啊,
while ($rw=DB::fetch($rs)){
$array[]=$rw;
$tupian = b.php?aid=$o[aid];
}
我这样加直接就报错了
我写的是语法不标准的示例,准确的是
$tupian = 'b.php?aid=' . $rw['aid'];
字符串要加引号

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

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.

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

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

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

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.

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

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


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

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
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor
