我正在开发一个多语言的利基社交网站.这意味着我们当前的URL结构很快将需要开始使用翻译的单词,如下所示:
www.example.com/home 变 www.example.com/inicio
www.example.com/profile 变 www.example.com/perfil
www.example.com/help 变 www.example.com/ayuda
等等.我的问题是:在PHP应用程序中支持这个的最佳方法是什么?对于传入的请求,我认为我的router.php文件中的以下字典就足够了:
<?php
$request = explode("/", trim($_SERVER['REQUEST_URI'], "/"));
// Dictionaries of page slugs.
$slugs = array(
'es' => array(
'inicio' => 'home',
'perfil' => 'profile',
'ayuda' => 'help',
)
// additional languages can be added here
);
// Rewrite any incoming (foreign) requests
if ($host=="www.example.es") { // to be made programmatic
$lang = "es"; // pick up from locale constant rather being hard-coded
if (array_key_exists($request[0], $slugs[$lang])) {
$request[0] = …Run Code Online (Sandbox Code Playgroud) 我正在从PayPal IPN脚本收到以下消息。从以下内容可以明显看出是什么导致IPN事务失败?如果没有,我该如何进一步调查问题?
[01/25/2010 7:49 PM] - FAIL: IPN Validation Failed.
IPN $_POST variables from PayPal:
mc_gross=25.00
protection_eligibility=Ineligible
address_status=unconfirmed
payer_id=AEVB83JZKDRCL
tax=0.00
address_street=1 Main Terrace
payment_date=10:49:52 Jan 25, 2010 PST
payment_status=Pending
charset=windows-1252
address_zip=W12 4LQ
first_name=Test
address_country_code=GB
address_name=Test User
notify_version=2.9
custom=
payer_status=unverified
address_country=United Kingdom
address_city=Wolverhampton
quantity=1
verify_sign=A0I1KzEZadt6mIDXxQkkIQCQKPTMAGvCuZ8RKXsOCujIi.RoMxAnbZXi
payer_email=test1_1263505944_per@example.com
txn_id=38A45069EV5838100
payment_type=instant
last_name=User
address_state=West Midlands
receiver_email=martin@example.com
pending_reason=unilateral
txn_type=web_accept
item_name=Ultimate Challenge UK Ressurection Standard Seating (25.00 GBP)
mc_currency=GBP
item_number=
residence_country=GB
test_ipn=1
handling_amount=0.00
transaction_subject=Ultimate Challenge UK Ressurection Standard Seating (25.00 GBP)
payment_gross=
shipping=0.00
IPN response from PayPal …Run Code Online (Sandbox Code Playgroud) 我正在建立一个网站,主要功能是地图搜索,并显示在英国各地发生的职业摔跤比赛.我正在使用谷歌地图JavaScript API的v3来实现这一目标,但我有一个问题,为什么我的应用程序的InfoWindows与maps.google.co.uk上的InfoWindows有所不同.
比较以下两个屏幕截图.矿:

谷歌地图网站:

为什么Google地图网站已经对InfoWindows进行了平方,为什么我的应用程序使用最新版本的Google Maps JavaScript API会对InfoWindows进行舍入?
我正在开发一个具有搜索工具的Expression Engine附加组件.
对于过去的搜索表单,我使用了标准HTML <form>,其method属性设置为GET,然后服务器端我将这些GET变量解析WHERE为数据库查询的某种形式的条件.
我正在尝试在Expression Engine附加组件中实现此逻辑,但似乎Expression Engine不喜欢带有查询字符串的URL,因为当我提交表单时,页面中断(它会引发404错误).
Expression Engine是否支持带有查询字符串的URL?或者这是否打破了内部路由?
我还应该提一下,这个附加组件将在许多站点上实现(数量未知),如果可能的话,我不想对Expression Engine核心文件(即PHP脚本)进行任何更改,以防万一有人建议.
提前致谢.
编辑:我想我会补充一些关于我想要实现的目标的澄清.
在过去,我使用$_GET变量来驱动搜索表单.所以我可能有一个像这样的URL:
如您所见,我的查询字符串包含名称和值对作为参数(包括一个用于page),这些将使用其action属性设置为的表单创建GET.
如果存在$_GET参数,那么search.php将解析它,将它们表达为SQL或XPATH查询或其他任何内容; 然后返回匹配的记录.然后,用户可以通过更新pageURL中存在的参数来翻阅这些记录; 查询将仅返回结果集的另一部分,因为其他GET参数仍将在URL中.
我想用Expression Engine附加组件实现相同的功能.我想要一个采用用户提交的标准的表单,然后返回一个可分页的记录集.我认为使用查询字符串将是最好的选择,因为它是RESTful和诸如此类的,但是前面提到的表达引擎不喜欢URL中存在的查询字符串,将其视为不同的URL并抛出404错误.
如何创建生成表单的加载项,然后使用提交的用户查询数据库表,并将结果返回给用户,然后也可以将页面?
我刚安装了CakePHP 2.0.2用于新项目.我正在尝试使用被调用的数据库配置,development但我的模型似乎没有提起它.
基于CakePHP 2的新目录和文件名约定,我在以下位置创建了以下内容/app/Model/AppModel.php:
<?php
class AppModel extends Model {
public $useDbConfig = 'development';
}
Run Code Online (Sandbox Code Playgroud)
但是,默认主页告诉我:
Cake无法连接到数据库.
然而,如果我在更改配置的名称/app/Config/database.php,以default将信息变为一个成功的消息,就好像它不拿起我的自定义AppModel类.
我该如何解决这个问题?正如新的CakePHP 2.0文档所说的$useDbConfig那样,如上所述使用该属性?
编辑:内容/app/Config/database.php:
class DATABASE_CONFIG {
public $development = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'root',
'password' => '',
'database' => 'cakephp_db',
'prefix' => '',
'encoding' => 'utf8',
);
}
Run Code Online (Sandbox Code Playgroud) 我想创建一个使用PHP以编程方式创建HTML表单的表单构建器,但我希望它是面向对象的.这让我看看PHP的DOM扩展,但它似乎在完整的HTML(和XML)文档的概念而不是DOM的部分.
因此,在PHP中是否可以以面向对象的方式创建HTML?例如,我的伪代码可能如下所示:
<?php
$form = new HTMLElement('form', array('method' => 'post', 'action' => 'contact.php'));
$fieldset = $form->addElement(new HTMLElement('fieldset'));
$fieldset->addElement(new HTMLElement('input', array(
'type' => 'text',
'name' => 'name'
)));
$fieldset->addElement(new HTMLElement('input', array(
'type' => 'email',
'name' => 'email'
)));
// and so on...
echo $form->asHTML();
Run Code Online (Sandbox Code Playgroud) 我正在研究库存控制系统,客户希望将他们的商品导出到他们的亚马逊商城帐户.到目前为止,我遇到了SubmitFeed端点.但是,我看到的所有示例仅显示了提交单个产品的示例.
正如亚马逊的文档所述,你一次只能拥有这么多活跃的Feed,我原本以为你能够在一个Feed中发送多个产品,这样你就不会耗尽Feed限制,因为我想卖家会想要的一次列出几十个甚至几百个产品.
我目前正在发送包含一个<Message>元素的XML文档,即
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
<Product>
<SKU>56789</SKU>
<StandardProductID>
<Type>ASIN</Type>
<Value>B0EXAMPLEG</Value>
</StandardProductID>
<ProductTaxCode>A_GEN_NOTAX</ProductTaxCode>
<DescriptionData>
<Title>Example Product Title</Title>
<Brand>Example Product Brand</Brand>
<Description>This is an example product description.</Description>
<BulletPoint>Example Bullet Point 1</BulletPoint>
<BulletPoint>Example Bullet Point 2</BulletPoint>
<MSRP currency="USD">25.19</MSRP>
<Manufacturer>Example Product Manufacturer</Manufacturer>
<ItemType>example-item-type</ItemType>
</DescriptionData>
<ProductData>
<Health>
<ProductType>
<HealthMisc>
<Ingredients>Example Ingredients</Ingredients>
<Directions>Example Directions</Directions>
</HealthMisc>
</ProductType>
</Health>
</ProductData>
</Product>
</Message>
Run Code Online (Sandbox Code Playgroud)
该<MessageID>元素表明我能够在feed中指定多个"消息",但我不确定语法,因为我希望<Message>它在一个<Messages>元素中,我可以在其中指定多个消息.
如何指定其他消息以及其他产品?还是我走错了轨道?
我有两个UITextInput控件,我想计算其中的字符数.
对于上下文,我有两个输入:一个用于电子邮件地址,一个用于密码.我还有一个"登录"按钮.默认情况下该按钮处于非活动状态,但只要在两个输入中输入至少一个字符,我将以编程方式启用该按钮.这是为了防止登录尝试,直到用户在两个字段中输入值.
到目前为止,我正在使用这种方法:
if count(emailInput.text) > 0 && count(passwordInput.text) > 0 {
// Enable button
} else {
// Disable button
}
Run Code Online (Sandbox Code Playgroud)
使用的count()功能是否可以接受?或者,还有更好的方法?我记得有一些问题需要检查iOS/Swift中的字符串长度.
AppoinmentList页面 - 我需要为此页面添加代码以更改迄今为止的毫秒数。有人可以帮助我吗?约会UnixTime": 1646274840000,
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'api_service.dart';
class AppoinmentList extends StatefulWidget {
int ts = 1646274840000;
final String? token;
AppoinmentList({
Key? key,
this.token,
}) :super(key: key);
@override
_AppoinmentListState createState() => _AppoinmentListState();
}
class _AppoinmentListState extends State<AppoinmentList> {
@override
void initState() {
super.initState();
APIService.getAppointmentList(widget.token!);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Appointment Listing"),
),
body: _appoinmentListUI(),
);
}
_appoinmentListUI() {
return FutureBuilder(
future: APIService.getAppointmentList(widget.token!),
builder: (
BuildContext context,
AsyncSnapshot<String?> model,
){
if …Run Code Online (Sandbox Code Playgroud) 我正在开发一个Facebook应用程序供页面使用.具有Web表单的页面必不可少,然后通过提交的数据创建数据库记录.没有什么太复杂的了.当我在处理发布数据时尝试区分网站时,会出现复杂性.这就是我所拥有的:
<?php
require_once('../lib/facebook.php');
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'cookie' => true
));
$signed_request = $facebook->getSignedRequest();
switch ($signed_request['page']['id']) {
case '144778562245193':
define('SITE_ID', '3');
define('SITE', 'UK Boxing Events');
define('DOMAIN', 'ukboxingevents.com');
define('BODY_CLASS', 'boxing');
break;
case '147183265335890':
define('SITE_ID', '1');
define('SITE', 'UK Wrestling Events');
define('DOMAIN', 'ukwrestlingevents.com');
define('ANALYTICS_ID', 'UA-xxxxxxx-xx');
define('BODY_CLASS', 'wrestling');
break;
case '157856417600021':
define('SITE_ID', '2');
define('SITE', 'UK MMA Events');
define('DOMAIN', 'ukmmaevents.com');
define('BODY_CLASS', 'mma');
break;
default:
die('Invalid page.');
break;
}
if (isset($_POST['add_event'])) {
// submit handler; writes to database
}
?> …Run Code Online (Sandbox Code Playgroud) php ×5
forms ×3
html ×3
amazon ×1
amazon-mws ×1
cakephp ×1
cakephp-2.0 ×1
dom ×1
facebook ×1
flutter ×1
google-maps ×1
http-post ×1
javascript ×1
multilingual ×1
paypal ×1
paypal-ipn ×1
swift ×1
uitextfield ×1
url-routing ×1